结束会话的MVC [英] End Session on MVC

查看:130
本文介绍了结束会话的MVC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样的问题,你可能知道答案......我的应用程序已经是功能齐全,做工精细。每当用户进行身份验证应用程序更新其与LastLoginDate模式,当用户注销时,应用程序更新其与LastLogOutDate模式。当用户点击保存注销链接能正常工作。然而,如果用户关闭LastLogOut值永远不会被更新了的窗口,以及发生的事情是管理员看到用户在线则不是。当用户离开别的工作和.NET失去会话同时打开的标签同样的事情发生。

I have this question you probably know the answer... My app is already functional and working fine. Whenever a user authenticates the app updates its model with the LastLoginDate, and when the user logs out the app updates its model with the LastLogOutDate. This works fine while the user keeps clicking on the logout link. However, if the user closes the windows the LastLogOut value never gets updated, and what happens is that Administrator sees users online that are not. The same thing happens when the user left the tab opened while working in something else and .NET loses session.

我不管理会话时间,也没有这样的任意值。所有我需要做的是:如果一段时间后没有用户,然后更新LastLogOut价值的活动,并设置在其模式为离线,定期的注销后。相同的,如果用户关闭了窗口,但我认为第一种情况会以两种方式工作。

I'm not managing the session time nor any value like that. All I need to do is: if after a while there is no activity of the user, then Update LastLogOut value and set it to offline in its model, after that logout regularly. Same if user closes the window, but I think first case will work in both ways.

我希望你能给我一只手在这个问题上,

I hope you could give me a hand on this issue,

感谢。

推荐答案

您将需要一个可追踪的 LastActivityTime 即得到更新任何GET / POST和也(可能配置)超时,说20分钟为当显示登录的用户会比较 LastActivityTime DateTime.Now ,只返回这些是超时窗口内。

You will need a trackable LastActivityTime that gets updated on any GET/POST and also a (possibly configurable) timeout, say 20 minutes that when showing logged in users will compare the LastActivityTime to DateTime.Now and only return those that are within the timeout window.

您还可以设置 LastLogOutDate LastActivityTime 加上超时时显示给管理员。

You can also set the LastLogOutDate to the LastActivityTime plus the timeout whenever displaying to the admin.

这篇关于结束会话的MVC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆