Accessing Session from inside a HTTPHandler
Here something I didn’t know before. By default, you cannot access the session from within an Asp.Net HttpHandler. To be able to do that, your handler class has to implement an extra interface:
System.Web.SessionState.IRequiresSessionState
So, the declaration of your class looks like this:
If you don’t do this, and try to access Session object from within the Handler code, then you will get an Null Object Reference exception. It didn’t take long to find out that it was the session which was giving the null exception, however it wasn’t intuitive.
If you found this content helpful, then please help by linking to me. You can also help me by sharing the content using any of these nifty buttons above. Thank you.
Similar posts from my blog (hopefully):
You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.





July 31st, 2009 at 9:35 pm
Would have wasted a lot of time figuring this out if it weren’t for your post.
Thanks a lot
August 5th, 2009 at 8:42 pm
You are welcome
December 15th, 2009 at 3:15 pm
not very helpfull. same problem exists by implementing as described.