Pregunta

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?

¿Fue útil?

Solución

The WebPageHttpModule module is registered using the RegisterModule method from the Microsoft.Web.Infrastructure.DynamicModuleHelper.DynamicModuleUtility class. Any module registered with this method will be registered after modules defined in the config file.

You could try registering your own module using this method. However, there's no way to guarantee that your module will be registered last. In most cases, the order shouldn't matter.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top