I am trying to set Session values using a IHttpModule. I have set the HttpModule to be used for all requests, not just managed/ASPX pages.
I found however, that when a request for a non-ASP.NET page came in (such as gif) the Session member of the HttpApplication would throw an exception or be null.
I found the following SO post for the reason behind this: link
When I am swapping out the HttpHandler with one that implements IRequiresSessionState the Session member is available in the HttpModule, and a Set-Cookie is sent back to the browser, but later when I try to read the contents of the session in a normal ASPX page none of the values I set are there. When debugging I can see that the SessionID is the same in both the HttpModule and normal ASPX page.
Do I need to do anything to force the session to be saved? I am assuming that while swapping in the fake HttpHandler initialises the Session, having to put the original which doesn't implement IRequiresSessionState back in causes the session to not be saved at the end of the request.