0

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?

amateur
  • 43,371
  • 65
  • 192
  • 320
  • For the first part, you can inspect the URL in your module and just return if it matches certain urls/requests. I'm not sure if there's a config option when setiting up your module to ignore certain requests. – Jonas Oct 27 '11 at 23:43
  • See this question for session issues in HttpModule. http://stackoverflow.com/q/276355/292060 – goodeye Dec 12 '14 at 20:53

1 Answers1

1

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

Steve Rowbotham
  • 2,868
  • 17
  • 18