ASP.NET Webforms routing with extension

[亡魂溺海] 提交于 2019-12-13 16:45:21

问题


I have a simple ASP.NET Webapplication project with url-routing and want to "allow" routes with the fileextension like ".html", e.g...

http://www.mywebsite.com/cms/test.html
http://www.mywebsite.com/cms/sub/test.html
http://www.mywebsite.com/cms/sub/sub/test.html

My global.asax routes looks like this:

routes.MapPageRoute("", "cms/{a1}", "~/default.aspx");

The route is matched with when i access the website like this: http://www.mywebsite.com/cms/test

If i try this one, it doens't work too:

routes.MapPageRoute("", "cms/{a1}.html", "~/default.aspx");

EDIT: Always i get an 404 error. I think that .net looks for the physical file...

Any ideas?


回答1:


I've fixed it on my on with the following property "runAllManagedModulesForAllRequests" inside the like this:

  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
    <handlers>
      <remove name="UrlRoutingHandler" />
    </handlers> 
  </system.webServer>


来源:https://stackoverflow.com/questions/16343195/asp-net-webforms-routing-with-extension

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!