|
Why Session_End is not fired?
|
This is one of the most frequently asked question.
1. Remember Session_End event is supported only in InProc mode.
2. Session_End will not be fired if you close your browser. HTTP is a stateless protocol, and the server has no way to know if your browser has closed or not.
3. Session_End will be fired only (i) after n minutes of inactivity (n = timeout value), or (ii) if someone calls Session.Abandon().
4.Session_End will be run by a background thread, which implies:
a. Your code in Session_End is running using the worker process account. You may have permission problem if you are accessing resource such as database.
b. If an error happens in Session_End, it will fail silently.
5. please note that in order for Session_End to be fired, your session state has to exist first. That means you have to store some data in the session state and has completed at least one request.
6. Session_End will be called only if the abandoned session is actually found. As a result, if you create and abandon a session inside the same request, because the session has not been saved and thus can not be found, Session_End will not be called.
|
|
|
|
|
|
|
|