IIS HttpModule cannot establish session

I am trying to set session values ​​using IHttpModule. I have installed HttpModule for all requests, not just managed / ASPX pages.

I found, however, that when a request came in for a nonASP.NET page (like a gif), the Session HttpApplication member would have thrown an exception or would have been null.

I found the following SO post for this reason: link

When I replace the HttpHandler with one that implements IRequiresSessionState, the session member is available in the HttpModule and the Set-Cookie is sent back to the browser, but later when I try to read the session content in a normal ASPX page, none of the values ​​I set are exist. When debugging, I can see that the SessionID is the same in the HttpModule page and normal ASPX.

Do I need to do anything to get the session to be persisted? My guess is that when replacing the fake HttpHandler initializes the session to deliver the original, which does not implement IRequiresSessionState, causes the session to not persist at the end of the request.

0


source to share


1 answer


I just worked, I had to move the override of the original HttpHandler from PostAcquireRequestState to PreRequestHandlerExecute.



+2


source







All Articles