I have a httpmodule set up in my asp.net web application, iis7, .net 4.0 etc. I have 2 issues I would like to resolve.
From debugging of the httpmodule, I have found that the module gets called for ScriptResource.axd ie. it runs when this is called. Is there any way I can prevent this or "turn it off"? I want to have the module run for some of my httphandlers, .asmx services and aspx page requests but dont want the overhead of being called for scriptresource handlers.
Secondling, is session state available in HttpModules and if so, what events is it available at?
As already mentioned, HttpModules
are enabled for all requests in an application so the only thing you can do is to inspect the incoming url in the HttpModule
and then decide what action to take based on that.
Session state is loaded during the AcquireRequestState
event so the earliest opportunity to inspect it from a HttpModule
is the PostAcquireRequestState
event. Session state is persisted at the point that the ReleaseRequestState
event is raised, so any changes you make to the session should be made before that point. You can therefore access session state at any point during the HttpApplication pipeline between those two events