问题
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)
{
context.Session ["Game"] = new Game (); // next time it is null
}
How do I persist values in Session state in ASP.NET ?
回答1:
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"/>
来源:https://stackoverflow.com/questions/5245868/how-do-i-persist-session-values-in-asp-net