IIS自带的http modules分别注册了HttpApplication pipeline里面的哪些事件

智慧并不产生于学历,而是来自对于知识的终生不懈的追求。这篇文章主要讲述IIS自带的http modules分别注册了HttpApplication pipeline里面的哪些事件相关的知识,希望能为你提供帮助。
  每个module的作用不同,会分别注册到所需要处理的事件。
事件本身的处理顺序是由pipeline决定的,如果多个module注册了同一个事件,触发的顺序按照注册事件的先后顺序来。注册的顺序,是由module的配置决定的。
 
C:WindowsSystem32inetsrvconfigapplicationHost.config

< modules> < add name="IsapiModule" lockItem="true" /> < add name="BasicAuthenticationModule" lockItem="true" /> < add name="HttpLoggingModule" lockItem="true" /> < add name="HttpCacheModule" lockItem="true" /> < add name="StaticCompressionModule" lockItem="true" /> < add name="DefaultDocumentModule" lockItem="true" /> < add name="DirectoryListingModule" lockItem="true" /> < add name="IsapiFilterModule" lockItem="true" /> < add name="ProtocolSupportModule" lockItem="true" /> < add name="StaticFileModule" lockItem="true" /> < add name="AnonymousAuthenticationModule" lockItem="true" /> < add name="RequestFilteringModule" lockItem="true" /> < add name="CustomErrorModule" lockItem="true" /> < add name="WindowsAuthenticationModule" lockItem="true" /> < add name="FailedRequestsTracingModule" lockItem="true" /> < add name="UrlAuthorizationModule" lockItem="true" /> < add name="HttpRedirectionModule" lockItem="true" /> < add name="ServerSideIncludeModule" lockItem="true" /> < add name="CertificateMappingAuthenticationModule" lockItem="true" /> < add name="DigestAuthenticationModule" lockItem="true" /> < add name="IISCertificateMappingAuthenticationModule" lockItem="true" /> < add name="IpRestrictionModule" lockItem="true" /> < add name="DynamicIpRestrictionModule" lockItem="true" /> < add name="CustomLoggingModule" lockItem="true" /> < add name="CgiModule" lockItem="true" /> < add name="FastCgiModule" lockItem="true" /> < add name="ApplicationInitializationModule" lockItem="true" /> < add name="WebSocketModule" lockItem="true" /> < add name="RewriteModule" /> < add name="OutputCache" type="System.Web.Caching.OutputCacheModule" preCondition="managedHandler" /> < add name="Session" type="System.Web.SessionState.SessionStateModule" preCondition="managedHandler" /> < add name="WindowsAuthentication" type="System.Web.Security.WindowsAuthenticationModule" preCondition="managedHandler" /> < add name="FormsAuthentication" type="System.Web.Security.FormsAuthenticationModule" preCondition="managedHandler" /> < add name="DefaultAuthentication" type="System.Web.Security.DefaultAuthenticationModule" preCondition="managedHandler" /> < add name="RoleManager" type="System.Web.Security.RoleManagerModule" preCondition="managedHandler" /> < add name="UrlAuthorization" type="System.Web.Security.UrlAuthorizationModule" preCondition="managedHandler" /> < add name="FileAuthorization" type="System.Web.Security.FileAuthorizationModule" preCondition="managedHandler" /> < add name="AnonymousIdentification" type="System.Web.Security.AnonymousIdentificationModule" preCondition="managedHandler" /> < add name="Profile" type="System.Web.Profile.ProfileModule" preCondition="managedHandler" /> < add name="UrlMappingsModule" type="System.Web.UrlMappingsModule" preCondition="managedHandler" /> < add name="ConfigurationValidationModule" lockItem="true" /> < add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" preCondition="managedHandler,runtimeVersionv4.0" /> < add name="ScriptModule-4.0" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" preCondition="managedHandler,runtimeVersionv4.0" /> < add name="ServiceModel-4.0" type="System.ServiceModel.Activation.ServiceHttpModule, System.ServiceModel.Activation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" preCondition="managedHandler,runtimeVersionv4.0" /> < add name="ServiceModel" type="System.ServiceModel.Activation.HttpModule, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" preCondition="managedHandler,runtimeVersionv2.0" /> < /modules>

 
 
 
//System.Web.Caching.OutputCacheModule // Token: 0x0600672E RID: 26414 RVA: 0x0016C418 File Offset: 0x0016A618 void IHttpModule.Init(HttpApplication app) { OutputCacheSection outputCache = RuntimeConfig.GetAppConfig().OutputCache; if (outputCache.EnableOutputCache) { app.ResolveRequestCache += this.OnEnter; app.UpdateRequestCache += this.OnLeave; } }

 
// System.Web.SessionState.SessionStateModule /// < summary> Calls initialization code when a < see cref="T:System.Web.SessionState.SessionStateModule" /> object is created.< /summary> /// < param name="app"> The current application. < /param> /// < exception cref="T:System.Web.HttpException"> The < see langword="mode" /> attribute in the sessionState Element (ASP.NET Settings Schema) configuration element is set to < see cref="F:System.Web.SessionState.SessionStateMode.StateServer" /> or < see cref="F:System.Web.SessionState.SessionStateMode.SQLServer" /> , and the ASP.NET application has less than < see cref="F:System.Web.AspNetHostingPermissionLevel.Medium" /> trust.< /exception> /// < exception cref="T:System.Configuration.ConfigurationErrorsException"> The < see langword="mode" /> attribute in the sessionState Element (ASP.NET Settings Schema) configuration element is set to < see cref="F:System.Web.SessionState.SessionStateMode.Custom" /> and the < see langword="customProvider" /> attribute is empty or does not exist.-or-The < see langword="mode" /> attribute in the sessionState Element (ASP.NET Settings Schema) configuration element is set to < see cref="F:System.Web.SessionState.SessionStateMode.Custom" /> and the provider identified by name in the < see langword="customProvider" /> attribute has not been added to the providers Element for sessionState (ASP.NET Settings Schema) sub-element.< /exception> // Token: 0x06001263 RID: 4707 RVA: 0x000333F0 File Offset: 0x000315F0 public void Init(HttpApplication app) { bool flag = false; SessionStateSection sessionState = RuntimeConfig.GetAppConfig().SessionState; if (!this.s_oneTimeInit) { SessionStateModule.s_lock.AcquireWriterLock(); try { if (!this.s_oneTimeInit) { this.InitModuleFromConfig(app, sessionState); flag = true; if (!SessionStateModule.CheckTrustLevel(sessionState)) { SessionStateModule.s_trustLevelInsufficient = true; } SessionStateModule.s_timeout = (int)sessionState.Timeout.TotalMinutes; SessionStateModule.s_useHostingIdentity = sessionState.UseHostingIdentity; if (sessionState.Mode == SessionStateMode.InProc & & this._usingAspnetSessionIdManager) { SessionStateModule.s_allowInProcOptimization = true; } if (sessionState.Mode != SessionStateMode.Custom & & sessionState.Mode != SessionStateMode.Off & & !sessionState.RegenerateExpiredSessionId) { SessionStateModule.s_allowDelayedStateStoreItemCreation = true; } SessionStateModule.s_configExecutionTimeout = RuntimeConfig.GetConfig().HttpRuntime.ExecutionTimeout; SessionStateModule.s_configRegenerateExpiredSessionId = sessionState.RegenerateExpiredSessionId; SessionStateModule.s_configCookieless = sessionState.Cookieless; SessionStateModule.s_configMode = sessionState.Mode; this.s_oneTimeInit = true; } } finally { SessionStateModule.s_lock.ReleaseWriterLock(); } } if (!flag) { this.InitModuleFromConfig(app, sessionState); } if (SessionStateModule.s_trustLevelInsufficient) { throw new HttpException(SR.GetString("Session_state_need_higher_trust")); } }

 
// System.Web.Profile.ProfileModule /// < summary> Calls initialization code when a < see cref="T:System.Web.Profile.ProfileModule" /> object is created.< /summary> /// < param name="app"> The current application. < /param> // Token: 0x06001427 RID: 5159 RVA: 0x0003AFD8 File Offset: 0x000391D8 public void Init(HttpApplication app) { if (ProfileManager.Enabled) { app.AcquireRequestState += this.OnEnter; if (ProfileManager.AutomaticSaveEnabled) { app.EndRequest += this.OnLeave; } } }

 
 
// System.Web.Security.WindowsAuthenticationModule /// < summary> Initializes the < see cref="T:System.Web.Security.WindowsAuthenticationModule" /> object.< /summary> /// < param name="app"> The current < see cref="T:System.Web.HttpApplication" /> instance. < /param> // Token: 0x06004D66 RID: 19814 RVA: 0x0010CA14 File Offset: 0x0010AC14 public void Init(HttpApplication app) { app.AuthenticateRequest += this.OnEnter; }

 
// System.Web.Security.FormsAuthenticationModule /// < summary> Initializes the < see cref="T:System.Web.Security.FormsAuthenticationModule" /> object.< /summary> /// < param name="app"> The current < see cref="T:System.Web.HttpApplication" /> instance. < /param> // Token: 0x06004BF8 RID: 19448 RVA: 0x00102EF4 File Offset: 0x001010F4 public void Init(HttpApplication app) { if (!FormsAuthenticationModule._fAuthChecked) { FormsAuthenticationModule._fAuthRequired = (AuthenticationConfig.Mode == AuthenticationMode.Forms); FormsAuthenticationModule._fAuthChecked = true; } if (FormsAuthenticationModule._fAuthRequired) { FormsAuthentication.Initialize(); app.AuthenticateRequest += this.OnEnter; app.EndRequest += this.OnLeave; } }

 
// System.Web.Security.DefaultAuthenticationModule /// < summary> Initializes the < see cref="T:System.Web.Security.DefaultAuthenticationModule" /> object.< /summary> /// < param name="app"> The current < see cref="T:System.Web.HttpApplication" /> instance. < /param> // Token: 0x06004B84 RID: 19332 RVA: 0x00100A9C File Offset: 0x000FEC9C public void Init(HttpApplication app) { if (HttpRuntime.UseIntegratedPipeline) { app.PostAuthenticateRequest += this.OnEnter; return; } app.DefaultAuthentication += this.OnEnter; }

 
 
// System.Web.Security.RoleManagerModule /// < summary> Associates the role manager with the specified application.< /summary> /// < param name="app"> The < see cref="T:System.Web.HttpApplication" /> to associate the < see cref="T:System.Web.Security.RoleManagerModule" /> with.< /param> // Token: 0x06004CC1 RID: 19649 RVA: 0x001060BA File Offset: 0x001042BA public void Init(HttpApplication app) { if (Roles.Enabled) { app.PostAuthenticateRequest += this.OnEnter; app.EndRequest += this.OnLeave; } }

 
// System.Web.Security.UrlAuthorizationModule /// < summary> Initializes the < see cref="T:System.Web.Security.UrlAuthorizationModule" /> object.< /summary> /// < param name="app"> The current < see cref="T:System.Web.HttpApplication" /> instance. < /param> // Token: 0x06004D51 RID: 19793 RVA: 0x0010C674 File Offset: 0x0010A874 public void Init(HttpApplication app) { app.AuthorizeRequest += this.OnEnter; }

 
// System.Web.Security.FileAuthorizationModule /// < summary> Initializes the < see cref="T:System.Web.Security.FileAuthorizationModule" /> object.< /summary> /// < param name="app"> The current < see cref="T:System.Web.HttpApplication" /> instance. < /param> // Token: 0x06004BA3 RID: 19363 RVA: 0x00101636 File Offset: 0x000FF836 public void Init(HttpApplication app) { app.AuthorizeRequest += this.OnEnter; }

 
// System.Web.Security.AnonymousIdentificationModule /// < summary> Initializes the < see cref="T:System.Web.Security.AnonymousIdentificationModule" /> object.< /summary> /// < param name="app"> The current < see cref="T:System.Web.HttpApplication" /> instance. < /param> // Token: 0x06004B4A RID: 19274 RVA: 0x000FF047 File Offset: 0x000FD247 public void Init(HttpApplication app) { if (!AnonymousIdentificationModule.s_Initialized) { AnonymousIdentificationModule.Initialize(); } if (AnonymousIdentificationModule.s_Enabled) { app.PostAuthenticateRequest += this.OnEnter; } }

 
// System.Web.UrlMappingsModule // Token: 0x0600104E RID: 4174 RVA: 0x0002D798 File Offset: 0x0002B998 public void Init(HttpApplication application) { UrlMappingsSection urlMappings = RuntimeConfig.GetConfig().UrlMappings; bool flag = urlMappings.IsEnabled & & urlMappings.UrlMappings.Count > 0; if (flag) { application.BeginRequest += this.OnEnter; } }

 
 
// System.Web.Routing.UrlRoutingModule /// < summary> Initializes a module and prepares it to handle requests.< /summary> /// < param name="application"> An object that provides access to the methods, properties, and events common to all application objects in an ASP.NET application.< /param> // Token: 0x0600139D RID: 5021 RVA: 0x00038BC8 File Offset: 0x00036DC8 protected virtual void Init(HttpApplication application) { if (application.Context.Items[UrlRoutingModule._contextKey] != null) { return; } application.Context.Items[UrlRoutingModule._contextKey] = UrlRoutingModule._contextKey; application.PostResolveRequestCache += this.OnApplicationPostResolveRequestCache; }

【IIS自带的http modules分别注册了HttpApplication pipeline里面的哪些事件】 

    推荐阅读