加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net – MembershipUser.IsOnline即使在注销后也是如此

发布时间:2020-12-15 22:45:06 所属栏目:asp.Net 来源:网络整理
导读:我正在使用Visual Studio 2010创建一个网站.我使用SQL Server 2008中的默认成员资格模式进行用户身份验证.现在我面临着以下问题. 当用户注销时,该用户的membership.IsOnline属性应设置为false.但是没有发生; member.IsOnline属性的用户仍然是真的. 我使用Log
我正在使用Visual Studio 2010创建一个网站.我使用SQL Server 2008中的默认成员资格模式进行用户身份验证.现在我面临着以下问题.

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

我使用LoginStatus控件为用户提供一个注销链接.

我试图跟随User.IsOnline = true even after FormsAuthentication.SignOut().但结果没有.

解决方法

AFAIK,FormsAuthentication.SignOut与会员制度没有直接关系.因此,您必须按照您在问题中提到的手动更新LastActivityDate.并使用 Membership.UserIsOnlineTimeWindow而不是-2.

从MSDN

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);

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读