Automatic redirect to login page after a certain time

1.3k views Asked by At

I am using form authentication. My code in web.config is:

<authentication mode="Forms">
  <forms loginUrl="~/Home/Index" timeout="5" />
</authentication>

I've used [Authorize] at the head of the actions, that need authentication to access. As my configuration in web.config after five minutes an user is redirected to "../Home/Index" if he/she tries to access an action or load a page that is need authentication to access. Is there any way to do it automatically. I mean if the system is idle, like though no one is using the system after five minutes it will automatically redirect to "../Home/Index" page.

1

There are 1 answers

0
Simon Whitehead On BEST ANSWER

Probably the easiest way is to add a meta-refresh tag to your Layout:

<meta http-equiv="refresh" content="310">

This will tell the browser to refresh the page every 5 minutes and 10 seconds. If the browser refreshes.. your timeout will kick in and redirect the user.