问题描述
我当前正在使用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, FormsAuthentication.SignOut 与会员系统没有直接关系.因此,您必须按照问题中的说明手动更新LastActivityDate
.并使用 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
MembershipUser user = Membership.GetUser(false);
FormsAuthentication.SignOut();
user.LastActivityDate = DateTime.UtcNow.AddMinutes(-(Membership.UserIsOnlineTimeWindow + 1));
Membership.UpdateUser(user);
这篇关于MembershipUser.IsOnline为true,即使注销后也是如此的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!