我想知道如何在asp.net MVC中的url中有这样的东西。
/第12.20.2013条
我尝试了以下方法,其工作罚款为/条/12-20-2013,但不适用/条款/12.20.2013。我在Global.asax里有下面的
routes.MapPageRoute("Blog",
"/Article/{entryDate}",
new {controller = "Article", action = "Entry")};我也尝试过以下的方法
routes.MapPageRoute("Blog",
"/Article/{month}.{Date}.{year}",
new {controller = "Article", action = "Entry")};但没有运气..。
请给我一些样品。
发布于 2013-08-09 05:25:16
我认为问题在于,IIS可能将".2013“视为文件扩展名,并试图为其查找处理程序。我们需要做的是让MVC流程所有的请求。
如果您在IIS 6上,则需要执行到aspnet_isapi.dll的通配符映射。如果您在IIS 7上,可以设置runAllManagedModulesForAllRequests="true"
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
</modules>
</system.webServer> 发布于 2013-08-09 04:40:02
您需要更改web.config,以强制每个以Article开头的url被视为MVC url。
<system.webServer>
<handlers>
<add name="UrlRoutingHandler"
type="System.Web.Routing.UrlRoutingHandler,
System.Web, Version=4.0.0.0,
Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a"
path="/Article/*"
verb="GET"/>
</handlers>
</system.webServer>那你的路线应该能正常工作。
https://stackoverflow.com/questions/18139975
复制相似问题