In my web.config <system.webServer>
section I add my custom module:
<modules>
<add name="MyCustomModule" type="MyAssembly.MyCustomModule, MyAssembly" />
</modules>
and then in my HTTP handler I iterate over the modules list:
var allModules = HttpContext.Current.ApplicationInstance.Modules;
for( int i = 0; i < allModules.Count; i++ ) {
Trace(allModules.GetKey(i));
}
and I get this list:
__ASP_IntegratedDynamicModule_Shim
OutputCache
Session
FormsAuthentication
DefaultAuthentication
RoleManager
AnonymousIdentification
Profile
UrlMappingsModule
ServiceModel-4.0
UrlRoutingModule-4.0
ScriptModule-4.0
MyCustomModule <<<<<<<<<<<<<My Module
__DynamicModule_System.Web.WebPages.WebPageHttpModule, System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35_2d022434-c92d-4088-bfa6-3478c4fc129d
Clearly my module is registered after all built-in modules except that WebPageHttpModule is registered after it.
How does that happen? How could I possibly ensure that my own module gets registered last?