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;
}
}
}
所以說所有 - 我不知所措,爲什麼它不清除會議...