IRequiresSessionState and session

IRequiresSessionState and session


   When you are accesing session values in HttpHandlers or HttpModule (custom HTTP handelr or module) , 

    you need to Inherit an interface called IRequiresSessionState 

 Implement the IRequiresSessionState interface in your custom HTTP handler to identify that your handler requires read and write access to session-state values.

http://msdn.microsoft.com/en-us/library/system.web.sessionstate.irequiressessionstate(v=VS.80).aspx

In your class library project don't forget to add a reference of System.Web to use IRequiresSessionState.

 e.g. 

  public class Handler : IHttpHandler,IRequiresSessionState 
  {
        public void ProcessRequest(HttpContext context)
       {
           // perform operation on request
          // Now you can store values into session and retrive it back
        } 
      
     public bool IsReusable
    {
        get
        {
            return false;
        }
    }
  }

 You can see we didn't implemented IRequiresSession at all. We just inherited it in handler calss.

Tags:

Sessions In AspnetHow are you using session variables in Asp.net with C#.netSession application viewstateSession Loss In Webgardensession objectsAsp.net Session TimeoutAsp.net SessionAsp.net Session AbandonOLE DB provider SQLNCLI for linked server returned message Cannot start more transactions on this sessionAsp.net Interview Questions for 2 years or 3 years experianceHow to implement Captcha in Asp.net

Author

My name is Satalaj, but people call me Sat. Here is my homepage: . I live in Pune, PN and work as a Software Engineer. I'm former MVP in ASP.net year 2010.
Disclaimer: Views or opinion expressed here are my personal research and it has nothing to do with my employer. You are free to use the code, ideas/hints in your projects. However, you should not copy and paste my original content to other web sites. Feel free to copy or extend the code.
If you want to fight with me, this website is not for you.
 

I'm Satalaj.