MembershipUser.LastActivityDate プロパティ
アセンブリ: System.Web (system.web.dll 内)

Dim instance As MembershipUser Dim value As DateTime value = instance.LastActivityDate instance.LastActivityDate = value
/** @property */ public DateTime get_LastActivityDate () /** @property */ public void set_LastActivityDate (DateTime value)
public function get LastActivityDate () : DateTime public function set LastActivityDate (value : DateTime)
メンバシップ ユーザーが最後に認証された日時またはアプリケーションにアクセスした日時。

ユーザーの LastActivityDate は、CreateUser メソッドと ValidateUser メソッドにより現在の日時に更新されます。また、GetUser メソッドのオーバーロードにより更新できる場合もあります。UpdateUser メソッドを使用して LastActivityDate プロパティを特定の日時に設定できます。
LastActivityDate は、ユーザーがオンライン中であるかどうかを判断するのに使用されます。現在の日時から UserIsOnlineTimeWindow プロパティ値を引いた日時がユーザーの LastActivityDate より前になる場合、ユーザーはオンライン中と見なされます。
SqlMembershipProvider は CreationDate、LastLoginDate、LastActivityDate、および LastPasswordChangedDate の各日時を、メンバシップ ユーザーが CreateUser メソッドによって作成されたときの日時に設定します。
![]() |
---|
ユーザーの LastActivityDate は、System.Web.Profile と System.Web.UI.WebControls.WebParts の名前空間内のクラスによって、ユーザー データがデータ ソースから取得されたり、データ ソースに設定されたりしたときに更新されます。アプリケーションが同じデータ ソースを使用してユーザー情報を格納し、ProfileProvider と PersonalizationProvider が MembershipProvider と同じ applicationName で構成されている場合、そのユーザーの LastActivityDate プロパティと IsOnline プロパティは、この動作を反映します。 |

すべてのメンバシップ ユーザー名を ListBox に表示し、選択したユーザー名に対応する特定のメンバシップ情報 (メンバシップ ユーザーの LastActivityDate プロパティ値など) をラベルに表示するコード例を次に示します。
<%@ Page Language="VB" %> <%@ Import Namespace="System.Web.Security" %> <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> <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>E-mail:</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="C#" %> <%@ Import Namespace="System.Web.Security" %> <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> <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>E-mail:</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>

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からMembershipUser.LastActivityDate プロパティを検索する場合は、下記のリンクをクリックしてください。

- MembershipUser.LastActivityDate プロパティのページへのリンク