How to access Session values from my custom HttpHandler in ASP.NET?
Copyright © 2007-2012 www.AspDotNetFaq.com
If you try to create a custom HttpHandler in ASP.Net just by creating a custom class that implements only the
IHttpHandler interface you will come across a strange limitation: your HttpHandler code wont be able to access the Session object, for example in the
ProcessRequest method.
This is because in order to access the Session object (and its values) from your custom HttpHandler you need to implement another interface:
IRequiresSessionState
(Don't worry, its just a marker interface and it does not enforce you to add any more methods to your class, it just 'tells' the ASP.NET runtime that you need to access the Session object in your code:
public class CaptchaImageGenerator : IHttpHandler, IRequiresSessionState
{
// your code that access the Session object comes here...
}
More info about the topic on this MSDN page:
IHttpHandler Interface
Copyright © 2007-2012 www.AspDotNetFaq.com