ASP.NET 为什么当我们关闭浏览器时没有调用 session_end 事件?
为什么当我们关闭浏览器时没有调用 session_end 事件?
Why session_end event is not getting called when we close a browser ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
因为当浏览器关闭时会话并没有结束。会话在超时或在服务器端显式结束时结束。
浏览器关闭实际上与服务器的连接无关。一旦页面完全加载(不包括一些时髦的ajax),连接就已经结束了。
Because the session doesn't end when the browser is closed. The session ends when it's timed out, or it is explicitly ended, server-side.
The browser closing really has nothing to do with the connection to the server. The connection is already over, once the page is fully loaded (excluding some funky ajax).
Silky 是对的,但是您可以尝试调用绑定到 onbeforeunload 事件的 ajax oneway 方法,并且在服务器上您可以处理此事件。但它可能不太可靠,并且不适用于所有浏览器。
Silky has right, but you can try call ajax oneway method binded to onbeforeunload event and on server you can handle this event. But it'll be probably not very reliable and works not in all browsers.