Jonathan
Jonathan

Reputation: 1669

How to expire a session when the system sits idle in asp.net mvc3

How can i expire a session when the system sits idle for some time. After completing that time it should be redirected to login page. I need to do this controller side. I am using asp.net mvc3 application.

Upvotes: 2

Views: 2026

Answers (1)

dove
dove

Reputation: 20702

The session will expire on the server when it times out.

If you want the browser to redirect at the same time you'd have to have a counter on the client, in JavaScript, which on 0 would do a redirect to your login page.

The controller cannot force the redirect of a browser without some action from the client. You could also look at having some kind of persistant connection like SignalR but that might be more than you need.

Another solution would be to have a refresh header like in this answer

ASP.NET Push Redirect on Session Timeout

Upvotes: 1

Related Questions