How do I persist session values in ASP.NET?
I'm implementing IHttpHandler
and IRequiresSessionState
and I'm using context.Session
but after I set up a value in Session, it's lost in the next request. What can I do to persist the values ?
$.ajax({
url: "/test.test",
type: "POST",
data: "{'type':'GetStep'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (result) {...}
});
The second call is similar to this, but the values that get set when I call this function are also lost on the next request.
public void ProcessRequest (HttpContext context)
{
开发者_Go百科 context.Session ["Game"] = new Game (); // next time it is null
}
How do I persist values in Session state in ASP.NET ?
Do you have session state defined in your web.config? Something like this
<sessionState mode="InProc" stateConnectionString="tcpip=127.0.0.1:42424" sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes" cookieless="false" timeout="20"/>
精彩评论