MVC noob here。ASP.net MVC 5 Session在调用Abandon之后未清除()
目前,我有这个代码,激发了我的的HomeController当通过AJAX页面加载:
namespace ETTData.Controllers
{
public class HomeController : Controller
{
[HttpPost]
public ContentResult clearSessions()
{
var currentSession = System.Web.HttpContext.Current.Session;
System.Diagnostics.Debug.WriteLine("BEFORE: " + currentSession.Timeout);
currentSession.Abandon();
//currentSession.RemoveAll();
//currentSession.Clear();
System.Diagnostics.Debug.WriteLine("AFTER : " + currentSession.Timeout);
return new ContentResult { Content = "OK", ContentType = "text/plain" };
}
}
}
的的Debug.WriteLine的输出是:
BEFORE:35
AFTER:35
因此,大家可以看到它有在之前但也有为后当它不应该,因为我用currentSession.Abandon等于什么();在调用该输出之前调用。
我通过的Global.asax.cs文件中设置会话超时:
namespace ETTData
{
public class MvcApplication : System.Web.HttpApplication
{
protected void Session_Start(Object sender, EventArgs e)
{
HttpContext.Current.Session.Timeout = 35;
}
}
}
所以说所有 - 我不知所措,为什么它不清除会议...