Login.OnLoggedIn(EventArgs) 메서드

정의

사용자가 웹 사이트에 로그인하여 인증되면 LoggedIn 이벤트가 발생합니다.

protected:
 virtual void OnLoggedIn(EventArgs ^ e);
protected virtual void OnLoggedIn (EventArgs e);
abstract member OnLoggedIn : EventArgs -> unit
override this.OnLoggedIn : EventArgs -> unit
Protected Overridable Sub OnLoggedIn (e As EventArgs)

매개 변수

e
EventArgs

이벤트 데이터를 포함하는 EventArgs입니다.

예제

다음 코드 예제에서는 이벤트를 사용하여 LoggedIn 사용자 로그인 레코드를 유지하는 사이트별 메서드를 호출합니다.

<%@ 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">
// This custom Login control uses a site-specific method
// to record the current date and time when users are 
// authenticated at the site.

class CustomLogin : Login
{
    private void SiteSpecificUserLoggingMethod(string UserName)
    {
        // Insert code to record the current date and time
        // when this user was authenticated at the site.
    }
    
    override protected void OnLoggedIn(EventArgs e)
    {
        SiteSpecificUserLoggingMethod(UserName);
    }
}
    // Add the custom login control to the page.
    void Page_Load(object sender, EventArgs e) 
    {
        CustomLogin loginControl = new CustomLogin();
        loginControl.ID = "loginControl";
        Placeholder1.Controls.Add(loginControl);
    }

</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:placeholder id="Placeholder1" runat="server"></asp:placeholder>
        </form>
    </body>
</html>
<%@ page language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
    ' This custom Login control uses a site-specific method
    ' to record the current date and time when users are 
    ' authenticated at the site.
    Class CustomLogin
        Inherits Login
        
        Private Sub SiteSpecificUserLoggingMethod(ByVal UserName As String)
            ' Insert code to record the current date and time
            ' when this user was authenticated at the site.
        End Sub
        
        Overrides Protected Sub OnLoggedIn(ByVal e As EventArgs)
            SiteSpecificUserLoggingMethod(UserName)
        End Sub
    End Class
    
    ' Add the custom login control to the page.
    Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
        Dim loginControl As New CustomLogin

        loginControl.ID = "loginControl"

        PlaceHolder1.Controls.Add(loginControl)
    End Sub
</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:placeholder id="Placeholder1" runat="Server"></asp:placeholder>
</form>
</body>
</html>

설명

OnLoggedIn 메서드는 LoggedIn 이벤트를 발생시킵니다. LoggedIn 이벤트를 사용하여 사용자가 인증된 후 사용자별 데이터 액세스와 같은 추가 처리를 제공합니다.

이벤트가 발생하면 대리자를 통해 이벤트 처리기가 호출됩니다. 자세한 내용은 이벤트 처리 및 발생합니다.

또한 OnLoggedIn 메서드를 사용하면 파생 클래스가 대리자를 연결하지 않고도 이벤트를 처리할 수 있습니다. 이는 파생 클래스에서 이벤트를 처리하는 기본 방법입니다.

상속자 참고

파생 클래스에서 OnLoggedIn(EventArgs)를 재정의하는 경우 등록된 대리자가 이벤트를 받도록 기본 클래스의 OnLoggedIn(EventArgs) 메서드를 호출해야 합니다.

적용 대상

추가 정보