HttpHandlers and Sessions in ASP.NET

After struggling for a little while with sessions in an http handler, I found that you need to implement either the IRequiresSessionState (if you need read/write access to sessions) or IReadOnlySessionState (for read only access) to be able to work with session in the httphandler. You will also need to add the System.Web.SessionState namespace to get it working.

I was trying to read a cookie and restore a particular session from an httphandler but without implementing the IRequiresSessionState, it did not work. So this is a nice little reminder for me!

comments powered by Disqus