views:

52

answers:

1

I have a HttpModule that hooks on 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.

A: 

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>
KP
As I wrote in the question a wildcard is defined but doesn't make any difference, EndRequest is still not triggered. Custom errors is not a solution to this problem, since it's doing a redirect and not a rewrite.
bang
Did you try deselecting 'verify the file exists' in IIS admin? This was the more important suggestion?
KP
Yes, the BeginRequest (= aspx isapi is involved) is triggered but if no handlers are assigned the request will be directed to the staticfilehandler, resulting in that EndRequest is NOT triggered. This is the behaviour in IIS6. In IIS7 the result is as expected (both BeginRequest and EndRequest is triggered).
bang
ah, got it now.. thx..
KP