web analytics

Session_End() event is not fired in global.asax.cs file

Options

codeling 1524 - 6369
@2021-06-03 08:39:01

Session end occurs on the server when the timeout is reached and the user may not even have their browser open when it occurs, it only fires at the end of the pipeline processing when an HTTP request has been received and a response has been rendered, that means it does NOT fire for a user who has simply closed their browser since HTTP is a stateless protocol and there is no way for the server to understand that the browser has been closed.

Also note that the session end event is only raised for InProc sessions, that means it t won't work with State Server, for example, or SQL-based session state.

@2021-06-03 09:10:23

Session_End event is fired by a worker process. This also means that Session_End event might not have all the permission that a normal page request has. So if you are trying to connect to the SQL server with Windows account, Session_End event might not have required permission, although you can connect to the SQL in Session_Start event.

Session_End will fire after a given amount of time where session has been inactive. The given time can be changed globally in the web.config file with the time out attribute or for individual session with the help of Session.Timeout property.

Session_End will also fire when someone calls the Session.Abondon method. Note that the Session_End event will not fire immediately. As said before the Session_End event is fired from worker process. Hence the session ID will also be same.

@2021-06-03 09:13:09

Server_MapPath, Request, Cache, HttpContext.Current, etc. cannot be used in the Session_End method.

Comments

You must Sign In to comment on this topic.


© 2021 Digcode.com