Reputation: 1118
During Session Start, one has access to the Request object. How about Session End, does it still have access to the Request object ? For example I want to count how many browsers are currently connected to my application.
Edit 1 : If Session End doesn't have access to Request Object, what info does it have access to ? Session ID, etc ?
Edit 2 : If Session End cannot be used to track disconnections, how does one track disconnections in ASP.Net ?
Thanks
Upvotes: 1
Views: 718
Reputation: 1118
Session_End will be fired if one is using InProc.
Session_End will be fired 1) after n minutes of inactivity (n = timeout value), or 2) if someone calls Session.Abandon()
Session_End doesn't get fired if one closes the browser.
Session_End requires session state to be set.
If one needs the original Request.Browser data, one should save it in Session State.
During Session_End, it has access to the Session State.
Upvotes: 1
Reputation: 8355
from the documentation
The Session_OnEnd event occurs when a session is abandoned or times out. Of the Server built-in objects, only the Application Object, Server Object, and Session Object objects are available.
Remarks
You cannot call the Server.MapPath method in the Session_OnEnd script. By default, Session_OnEnd runs as the Anonymous User, as defined for the application. In the event that there isn't an Anonymous user, or the Logon for the Anonymous user fails, the OnEnd function will not be called, and an event will be logged.
Upvotes: 0
Reputation: 144202
No, the Request object is not available in Session End.
Note too that Session End only fires when you call Session.Abandon() from code, not when a Session expires due to natural timeout or what-have-you. Consequently, it is not a reliable method to use for tracking disconnections.
Upvotes: 1