IHttpHandler and IRequiresSessionState

If your web application relies on session to persist the user’s state and you’ve ever tried writing your own HTTP handler, you’ve probably run into an error: “Session state is not available in this context”. Thankfully, there is a simple remedy.

In your class definition you need to implement the interface System.Web.SessionState.IRequiresSessionState. Once you’ve done that you’ll find yourself magically able to use session once more.

Leave a Reply