假设FirstModule
和SecondModule
都处理Application_BeginRequest
事件。它会按照web.config中定义的顺序执行吗?
<httpModules>
<add type="MyApp.FirstModule, MyApp" name="FirstModule"/>
<add type="MyApp.SecondModule, MyApp" name="SecondModule"/>
<add type="OtherApp.OtherModule, OtherApp" name="OtherModule"/>
</httpModules>
还有其他可以指定订单的方式吗?
最佳答案
根据this forum post,HttpModules以其注册的顺序执行。这对我来说很有意义,因为否则<clear>
和<remove>
指令也无法按预期运行,例如当这样使用时:
<httpModules>
<clear/>
<add... />
</httpModules>
关于asp.net - 如何确定HttpModules的执行顺序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2427451/