关于HttpModule事件顺序和执行顺序
2008-08-27 08:40
423 查看
总的来说,有如下事件会依次触发。
BeginRequest
AuthenticateRequest
AuthorizeRequest
ResolveRequestCache
AcquireRequestState
PreRequestHandlerExecute
PostRequestHandlerExecute
ReleaseRequestState
UpdateRequestCache
EndRequest
此外,有三个不确定的顺序:
PreSendRequestHeaders
PreSendRequestContent
Error 那么,当我们注册了多个Module之后会怎么样呢? 举个例子:
如果你在web.config配置了两个HttpModule,分别是HttpModuleA,HttpModuleB
这个事件执行的顺序如下:
HttpModuleA->BeginRequest
HttpModuleB->BeginRequest
HttpModuleA->AuthenticateRequest
HttpModuleB->AuthenticateRequest
HttpModuleA->AuthorizeRequest
HttpModuleB->AuthorizeRequest
...以此类推
当然了,系统默认的那些Module总是在自定义Module之前执行
Framework中默认的Module(C:\windows\microsoft.net\Framework\v2.0.50727\CONFIG\web.config)
<httpModules> <add name="OutputCache" type="System.Web.Caching.OutputCacheModule"/> <add name="Session" type="System.Web.SessionState.SessionStateModule"/> <add name="WindowsAuthentication" type="System.Web.Security.WindowsAuthenticationModule"/> <add name="FormsAuthentication" type="System.Web.Security.FormsAuthenticationModule"/> <add name="PassportAuthentication" type="System.Web.Security.PassportAuthenticationModule"/> <add name="RoleManager" type="System.Web.Security.RoleManagerModule"/> <add name="UrlAuthorization" type="System.Web.Security.UrlAuthorizationModule"/> <add name="FileAuthorization" type="System.Web.Security.FileAuthorizationModule"/> <add name="AnonymousIdentification" type="System.Web.Security.AnonymousIdentificationModule"/> <add name="Profile" type="System.Web.Profile.ProfileModule"/> <add name="ErrorHandlerModule" type="System.Web.Mobile.ErrorHandlerModule, System.Web.Mobile, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/> <add name="ServiceModel" type="System.ServiceModel.Activation.HttpModule, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/> </httpModules>
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }
相关文章推荐
- 关于HttpModule事件顺序和执行顺序
- [Log]ASP.NET之HttpModule 事件执行顺序
- HttpModule及其中的事件的执行顺序
- HttpModule模块里各事件的执行顺序
- HttpModule及其中的事件的执行顺序
- 了解IHttpModule接口事件执行顺便 获取Session
- HttpModule & httpHandle 执行顺序
- ASP.NET 2.0 页面事件执行顺序 --摘自http://www.cnblogs.com/china-dragon/archive/2009/11/21/1607761.html
- 了解IHttpModule接口事件执行
- 了解IHttpModule接口事件执行顺便 获取Session
- ASP.NET页面执行顺序 (HttpModule,HttpHandler)
- 了解IHttpModule接口事件执行
- 了解IHttpModule接口事件执行顺便 获取Session
- ASP.NET页面执行顺序 (HttpModule,HttpHandler)
- (asp.net session总为null得到解决)了解IHttpModule接口事件执行顺便 获取Session 和SQL
- HttpModule & httpHandle 执行顺序
- mvc全局过滤器和httpmodule的执行顺序
- HttpApplication事件执行顺序收藏
- ASP.NET中HttpApplication中ProcessRequest方法中执行的事件顺序;ASP.NET WebForm和MVC整体请求流程图
- HttpApplication事件执行顺序