HttpModule 的执行顺序是如何确定的?
假设 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>
还有其他方法可以指定顺序吗?
Suppose that both FirstModule
and SecondModule
handle the Application_BeginRequest
event. Will it execute in the order defined in the 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>
Are there other ways that the order can be specified?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据此论坛帖子,HttpModules按照它们注册的顺序执行。这对我来说很有意义,因为否则
和
指令也不会按预期工作,例如,当像这样使用时:According to this forum post, HttpModules are executed in the order in which they were registered. This makes sense to me, because otherwise the
<clear>
and<remove>
directives would also not work as expected, e.g. when used like this:根据 Internet 信息服务 (IIS) 7.0 资源Kit 书籍摘录自 Microsoft Press,
According to the Internet Information Services (IIS) 7.0 Resource Kit book extract from Microsoft Press,