C# 发送Json结果后,会话值变为null
我在controller中有一个方法,我通过ajax调用该方法:C# 发送Json结果后,会话值变为null,c#,.net,ajax,json,asp.net-mvc-4,C#,.net,Ajax,Json,Asp.net Mvc 4,我在controller中有一个方法,我通过ajax调用该方法: public JsonResult GetEbayOrders() { try { string EmailID = Session["EmailID"] as string; ------further using this emailid----- return js
public JsonResult GetEbayOrders()
{
try
{
string EmailID = Session["EmailID"] as string;
------further using this emailid-----
return json("whatever");
}
catch()
{
return json("whatever error");
}
}
在这里,我通过ajax和登录页面中的会话值单击一个按钮调用这个方法
我的问题是我第一次从会话中获得正确的值
一旦我返回结果,例如returnjson(“whatever”)。。。从下一次调用开始,会话的值变为null
我尝试从Global.asax将会话过期时间设置为80分钟
但同样的事情也发生在我身上
为什么我无法保留会话值???您在哪里设置此会话EmailID值?@Andrei在另一个控制器(loginController)中使用诸如Fiddler之类的检查器,您能否确认会话cookie存在于AJAX请求的标头中?