User inactivity with MVC3

Go To


How can I implement these scenarios using forms authentication?

If the user is Inactive for 40mins, he has to be logged out completely.


  • How should I set Session timeout ?
  • How to Manage application timeout vs. session timeout?
2012-04-04 18:26
by Brad


If the user has to enter password; he is essentially logged out. You can set session timeout to 20.

However if you really want to differentiate between the two you can update session item with last time user made a request. Set the session time out to 40 minutes. At any given time if the session last update entry is older than 20 minutes ask him to enter password again.

See the following for executing code before every request in MVC

2012-04-04 18:30
by Muhammad Hasan Khan
where should I write the code related to saving the Session["lastrequest"] in the application . and how should I assign the time to the Session["lastrequest"]Brad 2012-04-04 18:38
@Brad see the updated answe - Muhammad Hasan Khan 2012-04-04 18:51
Thanks @Hasan Khan for the links..... - Brad 2012-04-04 19:14