当资源丢失时,EndRequest 不会在 IIS 上触发
我有一个 HttpModule,它挂接到 IIS6 上的 EndRequest 事件,并注册了通配符处理程序,只要请求在 .aspx 页面上结束,它就可以正常工作,但如果 url 丢失 (404),则无法正常工作。
我猜这是因为 staticfilehandler 结束了请求,但是这个问题有什么好的解决方案吗?
我在 IIS7(管道模式)中尝试了相同的解决方案,并且工作正常。
I have a HttpModule that hooks on to the EndRequest Event on a IIS6 with a wildcard handler registered and it works fine as long as the request ends on a .aspx page, but NOT if the url is missing (404).
I guess it's because of the staticfilehandler ends the request, but is there any good solution for this problem ?
I have tried the same solution in IIS7 (pipeline mode) and there it works fine.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我要尝试的第一件事是告诉 IIS 不要验证文件是否存在,这将允许请求传递到 HttpModule。您可以对任何特定文件映射(包括通配符)执行此操作。
如果上述方法不可行,更糟糕的情况是,您可以在 web.config 中添加 404 错误的默认处理程序,这样,如果 HttpModule 无法捕获该事件,您仍然有机会“做某事” 。根据您尝试在 EndRequest 事件中完成的任务,您仍然可以使用解决方法。
First thing I'd try, is to tell IIS not to verify the file exists, which would allow the request to pass through to the HttpModule. You can do this for any particular file mapping, including the wildcard.
If the above isn't an option, worse case scenario you could add a default handler for the 404 error in the web.config, so that if the HttpModule can't catch the event, you still have a chance to 'do something'. Depending on what you are trying to accomplish in the EndRequest event, you may still be able to use the workaround.