asp.net – Session_End不启动?

前端之家收集整理的这篇文章主要介绍了asp.net – Session_End不启动?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
当他的会话超时时,我想登出一个用户。所以在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.

原文链接:https://www.f2er.com/aspnet/253082.html

猜你在找的asp.Net相关文章