ASP.NET路由 - 执行定制的路线完全跳过在Global.asax一切吗? [英] ASP.NET Routing - Do Custom Routes COMPLETELY SKIP Everything in the Global.asax?

查看:78
本文介绍了ASP.NET路由 - 执行定制的路线完全跳过在Global.asax一切吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的ASP.NET 3.5 SP1 Web窗体应用程序......我已经添加了System.Web.Routing DLL,和我做了一个返回标准的ASP.NET页面的IHttpHandler的一个简单途径

I have a simple ASP.NET 3.5 SP1 Web Forms app... I've added the System.Web.Routing DLL, and I've made a simple route that returns a standard ASP.NET Page as the "IHttpHandler".

所有这些都是好的......除了HttpContext.Current.User为 ???

All is good... except that HttpContext.Current.User is null ???

所以,我做了一个小挖多(我把断点在所有事件在Global.asax文件)。通常情况下,这些断点被击中(当我浏览到一个标准的的.aspx页面):

So, I did a little more digging (I put breakpoints in all the events in the Global.asax file). Normally, these breakpoints get hit (when I navigate to a standard ".aspx" page):


  • 的Application_BeginRequest

  • Application_AuthenticateRequest

  • Application_EndRequest

但是,使用ASP.NET路由时...没有这些事件被触发。我缺少的东西吗?

But, when using ASP.NET Routing... none of those events are firing. Am I missing something?

推荐答案

假设你正在使用IIS6,另一种方法是定义一个外卡扩展处理程序。加入这个简单的捕获所有映射IIS6将使它能够处理您的请求,无扩展名。默认情况下,.NET安装程序图的.aspx来,这就是为什么在.aspx扩建工程的aspnet_isapi.dll-。要映射没有扩展到APS.NET引擎的要求,你必须告诉IIS看的每次请求

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:

<一个href=\"http://haacked.com/archive/2008/11/26/asp.net-mvc-on-iis-6-walkthrough.aspx\">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

这篇关于ASP.NET路由 - 执行定制的路线完全跳过在Global.asax一切吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆