【发布时间】:2013-11-20 03:57:26
【问题描述】:
我正在 ASP.net 上打开一个文件进行编辑,直到会话结束,因为各种原因。 当用户从会话中注销时,我关闭打开的文件(来自 Session 变量),以便其他用户可以访问它。只要用户手动注销或会话时间到期,它就可以正常工作。 问题是,当用户在没有“退出”链接的情况下关闭浏览器时,不会从 Global.asax 文件中调用 Session_End 函数。 可能还有其他情况,如网络断开、浏览器崩溃、系统关闭等。
这是我在 Global.asax 文件中的代码
Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs when a session ends.
' Note: The Session_End event is raised only when the sessionstate mode
' is set to InProc in the Web.config file. If session mode is set to StateServer
' or SQLServer, the event is not raised.
' Code the close the File which is being stored in Session
End Sub
我正在寻找这些解决方案中的任何一个
- 如何在用户关闭浏览器时调用“Session_End”函数。
- 或者以后如何访问“未关闭的”会话变量以释放它们。
【问题讨论】: