Session_End中不火? [英] Session_End does not fire?
问题描述
我要登出一个用户时,他的会话超时。所以下面用在Global.asax中code:
I want to sign out a user when his session times out. So used following code in Global.asax:
protected void Session_End(object sender, EventArgs e)
{
FormsAuthentication.SignOut();
}
但似乎 Session_End中
永远不会触发。任何想法如何解决?我使用ASP.NET默认设置。
But seems session_end
never fires. Any idea how can fix it? I'm using ASP.NET with default settings.
推荐答案
您可以在session_start设置一些会话数据。没有这一点,Session_End中不会被解雇。
看到这
You may set some Session data in Session_Start. Without this, Session_End will not be fired. see this
另外这里需要注意的另外一个很重要的事情是,如果你没有在会话中保存任何的Session_End中的事件将不会触发。一定有什么东西在Session_End中触发事件,保存在会话ATLEAST一次。这也意味着,如果你在会话中保存的东西在第一个请求,并在同一请求放弃届Sesison_End事件不会火,因为没有什么保存在以往的会议。
Also another very important thing to note here is that if you do not save anything in the session the Session_End event will not fire. There must be something saved in the session atleast once for the Session_End event to fire. This also means that if you save something in the session in the first request and abandon the session in the same request the Sesison_End event will not fire, as there was nothing saved in the session ever.
这篇关于Session_End中不火?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!