简体   繁体   中英

Tracking logout time in ASP.net MVC web application

We have a task to implement tracking of user login and logout times. The only real problem we're facing is when and how to get the logout time of user. The application has a logout button but our users often just close the browser and then the user is automatically logged out.

Is there any way to get the time when the session ends?

You can use Session_End method in global.asax, just take the current time stamp in that method and do what you need to do.

protected void Session_End(Object sender, EventArgs e)
{
     var date = DateTime.Now();
     //Do stuff
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM