Membership.UserIsOnlineTimeWindow 属性

定义

指定用户在最近一次活动的日期/时间戳之后被视为联机的分钟数。Specifies the number of minutes after the last-activity date/time stamp for a user during which the user is considered online.

public:
 static property int UserIsOnlineTimeWindow { int get(); };
public static int UserIsOnlineTimeWindow { get; }
member this.UserIsOnlineTimeWindow : int
Public Shared ReadOnly Property UserIsOnlineTimeWindow As Integer

属性值

Int32

用户在最近一次活动的日期/时间戳之后被视为联机的分钟数。The number of minutes after the last-activity date/time stamp for a user during which the user is considered online.

示例

下面的代码示例显示了 ASP.NET 应用程序的 Web.config 文件部分中的 成员身份 元素 system.webThe following code example shows the membership element in the system.web section of the Web.config file for an ASP.NET application. 它指定应用程序使用的实例 SqlMembershipProvider ,并将 userIsOnlineTimeWindow 属性设置为20分钟。It specifies that the application use an instance of the SqlMembershipProvider and sets the userIsOnlineTimeWindow attribute to 20 minutes.

<membership defaultProvider="SqlProvider"  
  userIsOnlineTimeWindow="20">  
  <providers>  
    <add name="SqlProvider"  
      type="System.Web.Security.SqlMembershipProvider"  
      connectionStringName="SqlServices"  
      enablePasswordRetrieval="true"  
      enablePasswordReset="false"  
      requiresQuestionAndAnswer="true"  
      passwordFormat="Encrypted"  
      applicationName="MyApplication" />  
  </providers>  
</membership>  

注解

在对 UserIsOnlineTimeWindow 的调用过程中,将检查属性值 GetNumberOfUsersOnlineThe UserIsOnlineTimeWindow property value is checked during the call to GetNumberOfUsersOnline. 如果 LastActivityDate 用户的大于当前日期和时间减去 UserIsOnlineTimeWindow 值(以分钟为单位),则用户将被视为处于联机状态。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. 您可以使用类的属性确定成员资格用户是否被视为联机 IsOnline MembershipUserYou can determine whether a membership user is considered online with the IsOnline property of the MembershipUser class.

LastActivityDate当方法成功验证用户的凭据时,将更新用户的 ValidateUserThe LastActivityDate for a user is updated when a user's credentials are successfully validated by the ValidateUser method. 你还可以 LastActivityDate 在调用某个重载时为成员资格用户更新 GetUserYou can also update the LastActivityDate for a membership user when you call one of the GetUser overloads. 如果调用 GetUser 采用参数的重载 userIsOnline ,请将值指定 true 为,以便为用户更新 LastActivityDateIf you call a GetUser overload that takes a userIsOnline parameter, specify a value of true to update the LastActivityDate for the user.

适用于

另请参阅