ASP.NET Web表单与扩展路由 [英] ASP.NET Webforms routing with extension
本文介绍了ASP.NET Web表单与扩展路由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有URL路由一个简单的ASP.NET web应用项目,并希望为允许包含。html的的fileextension路线,例如...
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
我的Global.asax的路线是这样的:
My global.asax routes looks like this:
routes.MapPageRoute("", "cms/{a1}", "~/default.aspx");
这条路线与当我访问该网站是这样匹配:
http://www.mywebsite.com/cms/test
如果我试试这个,它好好尝试一下工作了:
If i try this one, it doens't work too:
routes.MapPageRoute("", "cms/{a1}.html", "~/default.aspx");
编辑:我总是得到一个404错误。我认为.NET查找物理文件...
Always i get an 404 error. I think that .net looks for the physical file...
任何想法?
推荐答案
我已经固定它在我与下列财产runAllManagedModulesForAllRequests里面是这样的:
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>
这篇关于ASP.NET Web表单与扩展路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文