Export (0) Print
Expand All

Login.LoggedIn Event

Occurs when the user logs in to the Web site and has been authenticated.

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in system.web.dll)

public event EventHandler LoggedIn
/** @event */
public void add_LoggedIn (EventHandler value)

/** @event */
public void remove_LoggedIn (EventHandler value)

In JScript, you can handle the events defined by a class, but you cannot define your own.
Not applicable.

The LoggedIn event is raised after the authentication provider checks the user's credentials and the authentication cookie is queued to send to the browser in the next response. Use the LoggedIn event to provide additional processing, such as accessing per-user data, after the user is authenticated.

When a user submits his or her login information, the Login control first raises the LoggingIn event, then the Authenticate event, and finally the LoggedIn event.

NoteNote:

When a user uses the Login control to log in to a Web site, all data in the view state and all post data is lost. Do not perform actions in the LoggedIn event that rely on the view state.

For more information about handling events, see Handling and Raising Events.

The following code example uses the LoggedIn event to call a site-specific method that keeps a record of user logins.

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

<script runat="server">
void SiteSpecificUserLoggingMethod(string UserName)
{
    // Insert code to record the current date and time
    // when this user was authenticated at the site.
}

void OnLoggedIn(object sender, EventArgs e)
{
    SiteSpecificUserLoggingMethod(Login1.UserName);
}
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
        <form id="form1" runat="server">
            <asp:Login id="Login1" runat="server" OnLoggedIn="OnLoggedIn"></asp:Login>

        </form>
    </body>
</html>

Windows 98, Windows Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

Community Additions

ADD
Show:
© 2014 Microsoft