gpt4 book ai didi

asp.net - Session_End 可以在窗口关闭时触发吗? (ASP.NET)

转载 作者:行者123 更新时间:2023-12-04 22:24:13 25 4
gpt4 key购买 nike

我在网站上放置了一个“在线”计数器,我遇到了这两个相互矛盾的来源。

这个(我正在使用这个示例代码):

http://aspdotnetfaq.com/Faq/How-to-show-number-of-online-users-visitors-for-ASP-NET-website.aspx

...说:

Also when user closes his browser or does not click on any links in our website, session expires, and our "OnlineUsers" global variable is decreased.



然而,这个:

http://www.velocityreviews.com/forums/t383710-session-end-guarantee.html

...说:

Closing the browser window, or browsing to another site will NOT cause Session_End to fire, at least, not straightaway - the server has absolutely no way of knowing what happens on the client machine until it gets another HttpRequest from it. In this instance, Session_End will fire when the session times out naturally.



我已经测试过,似乎 Session_End 不会触发。

我基本上希望你们对此进行确认或评论。

是否可以在浏览器关闭时更新在线计数器?

最佳答案

第二个是真的

Closing the browser window, or browsing to another site will NOT cause Session_End to fire, at least, not straightaway - the server has absolutely no way of knowing what happens on the client machine until it gets another HttpRequest from it. In this instance, Session_End will fire when the session times out naturally.



默认情况下, session 超时为 20 分钟。您可以通过在 20 分钟内不在您的网站上进行任何事件来确认这一点。

关于asp.net - Session_End 可以在窗口关闭时触发吗? (ASP.NET),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7943442/

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