开发者

Preventing Session Timeouts in asp.net mvc

i have a form where user enter some information. The problem is when they submit the form, due to session timeout, the page redirected to login page. After login they return to the same page but the form is empty and all information is lost which is very annoying for the user.

What is the best 开发者_StackOverflow中文版solution? I don't want to refresh the page. Should I send ajax request after every 5 minutes.

NOTE: The current Session Timeout is 40 minutes and it is stored in database.


If sliding expiration is enabled you could indeed poll the server at regular intervals to ensure that the session doesn't expire.


Pass the formcollection to the logon page to pass back to the form after redirecting.

EDIT: You can modify the action that the form posts to so that instead of sending unauthorized users to the logon action strait away you can have it first check if the user is authenticated then if not save the data somewhere (sql table or a cookie should be fine) and send the user to the logon action or continue to handle the data as normal. Have a parameter passed to the form action that indicates if and where to retrieve the saved data.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜