如何在模块之后注册WebPageHttpModule? [英] How does WebPageHttpModule happen to be registered after my modules?
问题描述
在我的web.config < system.webServer>
部分中,添加我的自定义模块:
In my web.config <system.webServer>
section I add my custom module:
<modules>
<add name="MyCustomModule" type="MyAssembly.MyCustomModule, MyAssembly" />
</modules>
,然后在我的HTTP处理程序中,遍历模块列表:
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));
}
我得到以下列表:
__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
很明显,我的模块是在所有内置模块之后注册的,除了WebPageHttpModule是在它之后注册的.
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?
推荐答案
WebPageHttpModule
模块使用RegisterModule 方法://msdn.microsoft.com/zh-cn/library/microsoft.web.infrastructure.dynamicmodulehelper.dynamicmoduleutility_methods%28v=vs.111%29.aspx"rel =" nofollow> Microsoft.Web.Infrastructure.DynamicModuleHelper.DynamicModuleUtility
类.使用此方法注册的任何模块都将在配置文件中定义的模块之后注册.
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.
这篇关于如何在模块之后注册WebPageHttpModule?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!