I have to maintain the user login and logout time in database. For login its easy but for logout , if I use Application_End ()
in global.asax
for logging. It gives me exception.
My Code in asax file:
Application_End()
{
HttpCurrent.Context.Session.Abandon();
LogUserLogoutTimeToDatabase();
}
You will need to use Session_End(). A user can simply close their browser, and to them, they are now "logged off" - but nothing has alerted the server that they have logged off unless they clicked a "log off" button before closing their browser. So, once their session times out, the Session_End() event will be triggered and you can capture your logout in there.