简体   繁体   English

防止ASP.NET MVC中的不活动注销

[英]prevent inactivity logout in asp.net mvc

In my application I have used several session variables, but not given any session timeout in web.config. 在我的应用程序中,我使用了多个会话变量,但在web.config中未指定任何会话超时。 I have used authentication mode as none in web.config. 我在web.config中使用身份验证模式作为无身份验证模式。 But after some inactivity time, its logging out and redirecting to login page. 但是经过一段不活动的时间后,其注销并重定向到登录页面。 It should remain and all operations should carry as it is even though I kept it inactive for hours (like GMail, until we click logout it will be there). 它应该保留,并且所有操作都应按原样进行,即使我将其保持几个小时处于非活动状态(例如GMail,直到我们单击注销,它也会在那里)。 Please assist me in resolving this inactivity session out issue. 请协助我解决此闲置会话问题。 It should not loose any sessions and operations should carry until I click explicitly "LogOut" 在我明确单击“注销”之前,它不应丢失任何会话和应该进行的操作

Best approach to handle this is, 最好的解决方法是

Save user session on the database and store session token in a COOKIE which will never expire (You have set cookie expiry as never expire) 将用户会话保存在数据库中,并将会话令牌存储在永不过期的COOKIE中(您已将cookie过期设置为永不过期)

That saved cookie and session data on database will be removed when user is logout (You have modify logout code to remove those). 用户注销后,将删除数据库上保存的cookie和会话数据(您可以修改注销代码以删除这些代码)。

As well as, if user clears all saved cookies on the web browser then, that saved session no longer valid and user will have to login again to your system again. 同样,如果用户在Web浏览器上清除了所有已保存的cookie,那么该已保存的会话将不再有效,用户将不得不再次登录到您的系统。 That is a obvious thing 那是显而易见的事情

FYI: This is the way exactly to enable Remember me feature. 仅供参考:这正是启用“ Remember me功能的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM