ASP.NET Routing - Do Custom Routes COMPLETELY SKIP Everything in the Global.asax?

眉间皱痕 提交于 2019-11-29 08:35:44

Assuming you're using IIS6, the alternative is to define a "wild card" extension handler. Adding this simple "catch all" mapping to IIS6 will enable it to process your extensionless requests. By default, the .NET installer maps ".aspx" to the aspnet_isapi.dll- that's why the .aspx extension works. To map requests with no extension to the APS.NET engine, you must tell IIS to look at every request.

Here's a quick article that explains the process:

http://haacked.com/archive/2008/11/26/asp.net-mvc-on-iis-6-walkthrough.aspx

Hope that helps and reduces the "lame" factor of your URLs. :)

-Todd

Found the freakish and bizzare (and stupid) answer :)

If you don't add ".aspx" to the end of your route, nothing fires in the Global.asax, meaning you don't get any BeginRequest, AuthenticateRequest, EndRequest, etc... Also, you don't get SessionState or anything.

So, the "fix" was for me to just change my route from this:

RouteTable.Routes.Add("Blah", new Route("Blah/{reportName}", new MyHandler());

to this:

RouteTable.Routes.Add("Blah", new Route("Blah/{reportName}.aspx", new MyHandler());

How completely lame :) ... but it's a fix none-the-less!

When you say

"If you don't add ".aspx" to the end of your route, nothing fires in the Global.asax, meaning you don't get any BeginRequest, AuthenticateRequest, EndRequest, etc... Also, you don't get SessionState or anything."

Will IIS log such requests in the log files or they are just anonymous? what about Application variables and ViewState?

sorry i haven't tested it yet, but just asking if you might already know?

i have checked application variable and Viewstate, these two are obviously working.. not sure about server logs :S

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