当他的会话超时时,我想登出一个用户。所以在Global.asax中使用以下代码:
protected void Session_End(object sender,EventArgs e) { FormsAuthentication.SignOut(); }
但似乎session_end从不触发。任何想法如何解决?我使用ASP.NET与默认设置。
解决方法
您可以在Session_Start中设置一些Session数据。没有这个,Session_End不会被触发。
见 this
见 this
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.