开发者

EndRequest not fired on IIS when resource is missing

开发者 https://www.devze.com 2022-12-18 15:03 出处:网络
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 th开发者_开发百科e request ends on a .aspx page, but NOT if the url

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 th开发者_开发百科e 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.


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.

<customErrors defaultRedirect="ErrorPage.aspx" mode="On">   
    <error statusCode="404" redirect="filenotfound.aspx" />
</customErrors>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号