我在 ASP.NET MVC 2 项目中配置了我的 Web.Config
文件,如下所示:
<sessionState mode="InProc" timeout="1"/>
并在Global.asax.cs
中添加以下内容:
protected void Session_End(object sender, EventArgs e)
{
System.Diagnostics.Debug.WriteLine("Session_End");
}
protected void Session_Start(object sender, EventArgs e)
{
System.Diagnostics.Debug.WriteLine("Session_Start");
}
当新用户访问网站时,将调用Session_Start()
。我本希望 Session_End()
在 1 分钟空闲时间后被调用,但事实并非如此。我错过了什么吗?
最佳答案
记住这一点:
顺便说一句: ASP.NET Session_End event not firingIf you don't save anything into the session, the session_end will not fire. If you're saving data in the session in the first request, and calling abandon in the same request the session_end will also not fired.
Hope this helps!
T
关于asp.net-mvc - ASP.NET MVC 中何时调用 Session_End()?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2373209/