User.IsOnline甚至FormsAuthentication.SignOut后=真() [英] User.IsOnline = true even after FormsAuthentication.SignOut()

查看:128
本文介绍了User.IsOnline甚至FormsAuthentication.SignOut后=真()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经设置UserIsOnlineTimeWindow =2在web.config中,然后我退出()函数已被修改为

I have set UserIsOnlineTimeWindow ="2" in web.config then my logout() function has been modified as

public ActionResult LogOff()
    {

        MembershipUser usr = Membership.GetUser();
        usr.LastActivityDate = DateTime.Now.AddMinutes(-2);
        FormsAuthentication.SignOut();
        return RedirectToAction("Index", "Home");
    }

注销后返回家后,仍然还在User.IsOnline = TRUE

Still after returning to Home after Logout still the User.IsOnline = true

只有2分钟的空闲时间后User.IsOnline = FALSE

Only after idle time of 2 minutes User.IsOnline = false

如何让用户在离线FormsAuthentication.SignOut();请帮助。

How to make the user Offline at FormsAuthentication.SignOut(); Please help.

推荐答案

不知道signOut也被认为是一个活动。

Not sure if signOut is also considered as an activity.

我建议你SignOut方法后设置LastActivityDate。而且不要忘了更新用户信息。

I suggest you set the LastActivityDate after the SignOut method. And don't forget to update the user info.

是这样的:

MembershipUser usr = Membership.GetUser(false);
FormsAuthentication.SignOut();
usr.LastActivityDate = DateTime.Now.AddMinutes(-2);
Membership.UpdateUser(usr);

我只是在我的应用程序进行测试,它的工作原理。

I just tested in my App, it works.

这篇关于User.IsOnline甚至FormsAuthentication.SignOut后=真()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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