MembershipUser.IsOnline为true,即使注销后也是如此 [英] MembershipUser.IsOnline is true even after logout

查看:135
本文介绍了MembershipUser.IsOnline为true,即使注销后也是如此的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我当前正在使用Visual Studio 2010创建一个网站.我正在使用SQL Server 2008中的默认成员资格架构进行用户身份验证.现在,我面临以下问题.

I'm currently creating a website using Visual Studio 2010. I'm using the default membership schema in SQL Server 2008 for user authentication. Now I'm facing the following problem.

当用户注销时,该用户的Membership.IsOnline属性应设置为false.但是,这没有发生;该用户的Membership.IsOnline属性仍然为true.

When a user logs out, the membership.IsOnline property of that user should be set to false. However that it is not happening; membership.IsOnline property of that user is still true.

我正在使用LoginStatus控件向用户提供注销链接.

I'm using the LoginStatus control to provide a logout link to the user.

我尝试遵循 User.IsOnline = true,即使在FormsAuthentication.SignOut之后也是如此().但是没有结果.

I have tried to follow User.IsOnline = true even after FormsAuthentication.SignOut(). But results nothing.

推荐答案

AFAIK, Membership.UserIsOnlineTimeWindow 代替-2.

AFAIK, FormsAuthentication.SignOut doesn't have a direct relationship to Membership system. Thus, you have to update the LastActivityDate manually as you mentioned in your question. And use Membership.UserIsOnlineTimeWindow instead of -2.

从MSDN

在调用过程中检查UserIsOnlineTimeWindow属性值 到GetNumberOfUsersOnline.如果用户的LastActivityDate为 大于当前日期和时间减去 以分钟为单位的UserIsOnlineTimeWindow值,则认为该用户 在线的.您可以确定是否考虑了会员用户 在线使用MembershipUser类的IsOnline属性.

The UserIsOnlineTimeWindow property value is checked during the call to GetNumberOfUsersOnline. If the LastActivityDate for a user is greater than the current date and time minus the UserIsOnlineTimeWindow value in minutes, then the user is considered online. You can determine whether a membership user is considered online with the IsOnline property of the MembershipUser class.

MembershipUser user = Membership.GetUser(false);

FormsAuthentication.SignOut();

user.LastActivityDate = DateTime.UtcNow.AddMinutes(-(Membership.UserIsOnlineTimeWindow + 1));
Membership.UpdateUser(user);

这篇关于MembershipUser.IsOnline为true,即使注销后也是如此的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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