C# 网页:管理退出事件或在服务器端无用户操作的情况下退出
当用户退出到其他页面而不执行任何操作时,管理退出或退出事件的更好解决方案是什么?此事件只需一次引发,可用于删除放弃此页面后未存储的所有临时文件或数据。是一种完美的服务器端清理方法。谢谢。
What is the better solution to manage Exit or Quit events when user exit to other pages with no action?. This event need to be raised only one time and be usefull to delete all temporary files or datas not stored after the abandon of this page. Is a perfect to use as cleaning method server side. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
网络是无状态的,所以不应该有任何东西需要清理。但是,有时您可能想在用户尝试关闭浏览器时终止会话。我想您可以捕获该事件,然后在关闭窗口之前调用服务器(使用 AJAX):
如何捕获浏览器窗口关闭事件?
恕我直言,不是 100% 可靠!
The web is stateless so there shouldn't really be anything to clean up. However, sometimes you may want to kill the session when the user tries to close browser. I guess you could catch that event and then call the server (using AJAX) before closing the window:
How to capture the browser window close event?
Not 100% reliable though IMHO!