I had a need to access the session state on the end of every request, even those on Response.Redirect. It sounds simple, and it is. It just took a while to find out what method is always called on every page before the data (headers and content) is sent back to the client. Even on Response.Redirect's.In the global.asax file, it is the method Application_PostRequestHandlerExecute. It is the last method that is called that has access to the session state. Here's a basic example:
using System;
usi