0

I'm going to save a variable in session by this:

context.Session["name"] = context.Request.Params["name"];
context.Response.Write(context.Session["name"]);

and the config file is this:

<configuration>
   <system.web>
       <compilation debug="true" targetFramework="4.0" />
       <sessionState cookieless="false" mode="StateServer" timeout="10000"  
           stateConnectionString="tcpip=127.0.0.1:42424">
       </sessionState>
    </system.web>
</configuration>

but I got this error: Object reference not set to an instance of an object.

What is wrong with my code?

Super Hornet
  • 2,839
  • 5
  • 27
  • 55

1 Answers1

1

Your HttpHandler needs to implement the IRequireSessionState interface, otherwise Session is not available to the handler.

Karl Anderson
  • 34,606
  • 12
  • 65
  • 80