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.
网络是无状态的,所以不应该有任何东西需要清理。但是,有时您可能想在用户尝试关闭浏览器时终止会话。我想您可以捕获该事件,然后在关闭窗口之前调用服务器(使用 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!