How to implement session Time out page to show using asp.net mvc
I have this in my webconfig file...
<authentication mode="Forms">
<forms loginUrl="~/Account/LogOn" timeout="2880" />
</authenticati开发者_如何学Con>
timeout 2880 means how much sec or min its going to take?
How to show when my session time out I need to display SessionTimeout.aspx page...
Thanks
You can identify a session time out in MVC with an action filter. Here is a question I asked about the issue. And the time listed is in minutes. (check comments for link)
As Gabriel said, with FormsAuthentication the timeout will happen behind the scenes meaning your user will be asked to log in again if they access a page after the time has expired.
I would suggest looking into adding slidingExpiration="true" to your web.config.
Also, you might want to implement an automatic logoff so potentially sensitive data isn't left exposed once the timeout is reached.
I did this by calling window.setTimeout(myFunction, 30000) with each page load if the user was authenticated. That function uses JQuery ajax to hit an action that returns the amount of time left before the session expires. Once the amount of time goes below zero, you can redirect to a logoff action via JavaScript. Otherwise that method simply calls window.setTimeout(myFunction, 30000) again so it continues to check.
You can get fancier by adding a warning message and allowing the user to click a button that uses JQuery ajax to hit an action that resets the timer.
Make a counter in javascript and when the time-out is reached redirect the user.
Edit: As I understood your question you wanted to redirect to the page when a user has been inactive for too long yes?
精彩评论