The event in the global.asax file is written like this:
protected void Session_End(Object sender, EventArgs e)
{
var x = 5;
}
The code does not reach there when the client close the window, why?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Because this event is not supposed to be invoked when the client closes his browser. This event (as its name suggests) is intended to be invoked when the session expires. The default session expiration timeout is 20 minutes so this event will be invoked 20 minutes after the client has closed his browser.
Oh and there’s a very important gotcha you should be aware of: if you are using an out-of-process session state mode (such as StateServer or SqlServer) this event will never be invoked.