带后缀的自定义属性路由

时间:2014-11-13 11:03:48

标签: asp.net-mvc asp.net-mvc-5 asp.net-mvc-routing routeattribute

我想创建这样的网址:

www.example.com/Content/page.html

在我使用的ContentControler之上:

[RoutePrefix("Home")]

在我使用的索引操作之上:

[Route("page.html")]

但是当我请求此网址时,会发生此错误:

HTTP Error 404.0 - Not Found

我怎么能解决这个问题? 谢谢你的帮助

1 个答案:

答案 0 :(得分:0)

您需要更改web.config才能使其正常运行。在下面的行中添加:

<system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
</system.webServer>

有关此操作的详细信息:http://www.iis.net/configreference/system.webserver/modules

相关问题