gpt4 book ai didi

asp.net - Session_End 不触发?

转载 作者:行者123 更新时间:2023-12-02 09:50:31 25 4
gpt4 key购买 nike

我想在用户 session 超时时注销该用户。因此在 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.

关于asp.net - Session_End 不触发?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4813462/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com