I am working on ASP.net to open a file for edit till the session ends for various reasons exclusively. When user Logout from the session I close the opened file (from the Session variable) so that other users can access it. It works fine as long as user Signout manually or Session time expires. The issue is, when user close the browser without "Signout" link, the Session_End function not being called from Global.asax file. There may be other scenarios like, Net disconnect, browser crash, System shutdown etc.
Here is my code in Global.asax file
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
I am looking either of these solutions
- How to call the "Session_End" function when user close the browser.
- Or how to access the "unclosed" Session variables later on to free them.