Four our current .aspx website we have a custom HttpModule which does the Authorization (which user can see what). I've rebuilt our old .aspx website to MVC. And because our clients won't all en masse switch to the MVC website I can't use MVC's Action filters, but I need to continue to use the HttpModule.
The problem is that I get Http error 404.
What I've done: - MVC application is bin deployed properly (this is verified because without the HttpModule configured in IIS it works fine); - Appropiate configurations in the Web.Config and IIS7.5 for the HttpModule are made (this is verified because I write logentries to a file from the HttpModule to see if the module gets called in the first place and runs as expected)
Web.config file:
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<add name="WebHIS_Authorization" type="WebHIS_Authorization.AuthorizationModule" />
</modules>
</system.webServer>
So everything seems to work fine. BeginRequest of the HttpModule is entered according to the log. I've even verified in my logfile that right before the HttpModule leaves the BeginRequest method the URL is still as expected. But it simply seems as if the MVC routing doesn't work anymore after the HttpModule is left by the HttpRequest and IIS returns 404. I hope I can be helped.
If you need to see specific things please ask and I'll provide the appropiate information.
I'm not sure why yet. But we got the above error because we tried to handle all events of the HTTP request lifecycle. We've added handlers on the events:
BeginRequest
AuthenticateRequest
AuthorizeRequest
ResolveRequestCache
AcquireRequestState
PreRequestHandlerExecute
PostRequestHandlerExecute
ReleaseRequestState
UpdateRequestCache
EndRequest
While we only need BeginRequest (we logged the other events for future references). So we removed the handlers on all the other events and left the handler on BeginRequest and we didn't get the http error anymore.
I'm sorry I don't have specific information as to why this behaviour occured. I found this out by trial & error. Hopefully this thread can help others in the future.