我正在使用Visual Studio 2010创建一个网站.我使用sql Server 2008中的默认成员资格模式进行用户身份验证.现在我面临着以下问题.
当用户注销时,该用户的membership.IsOnline属性应设置为false.但是没有发生; member.IsOnline属性的用户仍然是真的.
我试图跟随@L_403_0@.但结果没有.
解决方法
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);