Search code examples
c#asp.netsessionsession-variables

Object reference not set to an instance of an object. httphandler session


I am receiving "Object reference not set to an instance of an object." when I am trying to add access token from fb to the httpcurrent.session object.

I have the value in the var accessToken and when I am trying to put it in the session I am getting the error.

Please refer to the image:

enter image description here


Solution

  • You need to enable session state in an HttpHandler, so you have to implement

    System.Web.SessionState.IRequiresSessionState
    

    Change to the following:

    public class FacebookLogin : IHttpHandler, System.Web.SessionState.IRequiresSessionState