Points related to Session_End event

Important points related to Session_End event:


1. While thinking of Session_End event one of the most important things is that the event is supported only when the session is maintained Inproc. The session_End event will not fire if you are using State server or SQL server.

2. Another important point to note is that 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.

3. 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.

4. 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.

5. Remember the Session_End event will not fire in case the user closes the browser. HTTP is a stateless protocol. There is no way for the server to understand that the browser has been closed.

6. Also another very important thing to note here is that if you do not save anything in the session the Session_End event will not fire. There must be something saved in the session atleast once for the Session_End event to fire. This also means that if you save something in the session in the first request and abandon the session in the same request the Sesison_End event will not fire, as there was nothing saved in the session ever.


7. Response.Redirect cannot be used in Session_End event.

Comments

Popular posts from this blog

Data Bound Controls in ASP.Net - Part 4 (FormView and DetailsView controls)

ASP.net: HttpHandlers

The Clickjacking attack and X-Frame-Options