MembershipUser.LastActivityDate Özellik

Tanım

Üyelik kullanıcısının en son kimliğinin doğrulandığı veya uygulamaya eriştiği tarih ve saati alır veya ayarlar.

public:
 virtual property DateTime LastActivityDate { DateTime get(); void set(DateTime value); };
public virtual DateTime LastActivityDate { get; set; }
member this.LastActivityDate : DateTime with get, set
Public Overridable Property LastActivityDate As DateTime

Özellik Değeri

Üyelik kullanıcısının son kimliğinin doğrulandığı veya uygulamaya eriştiği tarih ve saat.

Örnekler

Aşağıdaki kod örneği, bir ListBox denetimdeki tüm üyelik kullanıcı adlarını görüntüler ve üyelik kullanıcısının özellik değeri de dahil olmak üzere LastActivityDate seçili kullanıcı adı için belirli üyelik bilgilerini göstermek için etiketleri kullanır.

<%@ Page Language="C#" %>
<%@ Import Namespace="System.Web.Security" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">

MembershipUserCollection users;

public void Page_Load()
{
  users = Membership.GetAllUsers();

  if (!IsPostBack)
  {
    // Bind users to ListBox.
    UsersListBox.DataSource = users;
    UsersListBox.DataBind();
  }


  // If a user is selected, show the properties for the selected user.

  if (UsersListBox.SelectedItem != null)
  {
    MembershipUser u = users[UsersListBox.SelectedItem.Value];

    EmailLabel.Text = u.Email;
    IsOnlineLabel.Text = u.IsOnline.ToString();
    LastLoginDateLabel.Text = u.LastLoginDate.ToString();
    CreationDateLabel.Text = u.CreationDate.ToString();
    LastActivityDateLabel.Text = u.LastActivityDate.ToString();
  }
}

</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Sample: View User Information</title>
</head>
<body>

<form runat="server" id="PageForm">

  <h3>View User Information</h3>

  <table border="0" cellspacing="4">
    <tr>
      <td valign="top">
        <asp:ListBox id="UsersListBox" DataTextField="Username" 
                     Rows="8" AutoPostBack="true" runat="server" />
      </td>
      <td valign="top">
        <table border="0" cellpadding="2" cellspacing="0">
          <tr>
           <td>Email:</td>
           <td><asp:Label runat="server" id="EmailLabel" /></td>
          </tr>
          <tr>
           <td>Is Online?:</td>
           <td><asp:Label runat="server" id="IsOnlineLabel" /></td>
          </tr>
          <tr>
           <td>LastLoginDate:</td>
           <td><asp:Label runat="server" id="LastLoginDateLabel" /></td>
          </tr>
          <tr>
           <td>CreationDate:</td>
           <td><asp:Label runat="server" id="CreationDateLabel" /></td>
          </tr>
          <tr>
           <td>LastActivityDate:</td>
           <td><asp:Label runat="server" id="LastActivityDateLabel" /></td>
          </tr>
        </table>
      </td>
    </tr>
  </table>

</form>

</body>
</html>
<%@ Page Language="VB" %>
<%@ Import Namespace="System.Web.Security" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">

Dim users As MembershipUserCollection

Public Sub Page_Load()
  users = Membership.GetAllUsers()

  If Not IsPostBack Then
    ' Bind users to ListBox.
    UsersListBox.DataSource = users
    UsersListBox.DataBind()
  End If


  ' If a user is selected, show the properties for the selected user.

  If Not UsersListBox.SelectedItem Is Nothing Then
    Dim u As MembershipUser = users(UsersListBox.SelectedItem.Value)

    EmailLabel.Text = u.Email
    IsOnlineLabel.Text = u.IsOnline.ToString()
    LastLoginDateLabel.Text = u.LastLoginDate.ToString()
    CreationDateLabel.Text = u.CreationDate.ToString()
    LastActivityDateLabel.Text = u.LastActivityDate.ToString()
  End If
End Sub

</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Sample: View User Information</title>
</head>
<body>

<form runat="server" id="PageForm">

  <h3>View User Information</h3>

  <table border="0" cellspacing="4">
    <tr>
      <td valign="top">
        <asp:ListBox id="UsersListBox" DataTextField="Username" 
                     Rows="8" AutoPostBack="true" runat="server" />
      </td>
      <td valign="top">
        <table border="0" cellpadding="2" cellspacing="0">
          <tr>
           <td>Email:</td>
           <td><asp:Label runat="server" id="EmailLabel" /></td>
          </tr>
          <tr>
           <td>Is Online?:</td>
           <td><asp:Label runat="server" id="IsOnlineLabel" /></td>
          </tr>
          <tr>
           <td>LastLoginDate:</td>
           <td><asp:Label runat="server" id="LastLoginDateLabel" /></td>
          </tr>
          <tr>
           <td>CreationDate:</td>
           <td><asp:Label runat="server" id="CreationDateLabel" /></td>
          </tr>
          <tr>
           <td>LastActivityDate:</td>
           <td><asp:Label runat="server" id="LastActivityDateLabel" /></td>
          </tr>
        </table>
      </td>
    </tr>
  </table>

</form>

</body>
</html>

Açıklamalar

LastActivityDate bir kullanıcı için, ve CreateUser yöntemleri tarafından ValidateUser geçerli tarih ve saate güncelleştirilir ve yöntemin GetUser bazı aşırı yüklemeleriyle güncelleştirilebilir. özelliğini belirli bir tarih ve saate ayarlamak UpdateUser için yöntemini kullanabilirsinizLastActivityDate.

LastActivityDate, kullanıcının çevrimiçi olup olmadığını belirlemek için kullanılır. Geçerli tarih ve saat eksi özellik değeri kullanıcı için değerinden UserIsOnlineTimeWindow önceyse LastActivityDate , kullanıcı çevrimiçi olarak kabul edilir.

, SqlMembershipProvider , CreationDateLastLoginDateve LastActivityDate tarihlerini, yöntemi tarafından LastPasswordChangedDate üyelik kullanıcısı oluşturulduğunda aynı tarih ve saate ayarlarCreateUser.

Note

LastActivityDate Kullanıcı için, veri kaynağından kullanıcı verileri alındığında veya veri kaynağında ayarlandığında ve System.Web.Profile ad alanları içindeki sınıflar System.Web.UI.WebControls.WebParts tarafından güncelleştirilir. Uygulamanız kullanıcı bilgilerini depolamak için aynı veri kaynağını kullanıyorsa ve ProfileProvider ve PersonalizationProvider 'niz ile applicationNameaynı MembershipProvider şekilde yapılandırılmışsaLastActivityDate, kullanıcının ve IsOnline özellikleri bu davranışı yansıtır.

Şunlara uygulanır

Ayrıca bkz.