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.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5