加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net – Session_End不启动?

发布时间:2020-12-16 00:45:01 所属栏目:asp.Net 来源:网络整理
导读:当他的会话超时时,我想登出一个用户。所以在Global.asax中使用以下代码: protected void Session_End(object sender,EventArgs e){ FormsAuthentication.SignOut();} 但似乎session_end从不触发。任何想法如何解决?我使用ASP.NET与默认设置。 解决方法 您
当他的会话超时时,我想登出一个用户。所以在Global.asax中使用以下代码:
protected void Session_End(object sender,EventArgs e)
{
    FormsAuthentication.SignOut();
}

但似乎session_end从不触发。任何想法如何解决?我使用ASP.NET与默认设置。

解决方法

您可以在Session_Start中设置一些Session数据。没有这个,Session_End不会被触发。
见 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.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读