Login.LoggingIn 이벤트

정의

사용자가 로그인 정보를 전송한 후 인증이 수행되기 전에 발생합니다.

public:
 event System::Web::UI::WebControls::LoginCancelEventHandler ^ LoggingIn;
public event System.Web.UI.WebControls.LoginCancelEventHandler LoggingIn;
member this.LoggingIn : System.Web.UI.WebControls.LoginCancelEventHandler 
Public Custom Event LoggingIn As LoginCancelEventHandler 

이벤트 유형

예제

다음 코드 예제에서는 합니다 LoggingIn 사용자가 올바른 형식의 전자 메일 주소를 입력 했는지 확인 하는 이벤트를 UserName 속성입니다. 그렇지 않은 LoggingIn 경우 이벤트는 로그인 시도를 취소하고 속성을 사용하여 InstructionText 오류 메시지를 표시합니다.

<%@ Page Language="C#" %>
<%@ Import Namespace="System.ComponentModel" %>
<%@ Import Namespace="System.Text.RegularExpressions" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

bool IsValidEmail(string strIn)
{
    // Return true if strIn is in valid email format.
    return Regex.IsMatch(strIn, @"^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$"); 
}

void OnLoggingIn(object sender, System.Web.UI.WebControls.LoginCancelEventArgs e)
{
    if (!IsValidEmail(Login1.UserName))
    {
        Login1.InstructionText = "You must enter a valid email address.";
        e.Cancel = true;
    }
    else
    {
        Login1.InstructionText = String.Empty;
    }
}

</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" 
                OnLoggingIn="OnLoggingIn" 
                UserNameLabelText="Email Address:" 
                UserNameRequiredErrorMessage="Email Address.">
            </asp:Login>
        </form>
    </body>
</html>
<%@ Page Language="VB" %>
<%@ Import Namespace="System.ComponentModel" %>
<%@ Import Namespace="System.Text.RegularExpressions" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

Function IsValidEmail(ByVal strIn As String) As Boolean
    ' Return true if strIn is in valid email format.
    Return Regex.IsMatch(strIn, ("^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$"))
End Function

Sub OnLoggingIn(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.LoginCancelEventArgs)
    If Not IsValidEmail(Login1.UserName) Then
        Login1.InstructionText = "You must enter a valid email address."
        e.Cancel = True
    Else
        Login1.InstructionText = String.Empty
    End If
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:Login id="Login1" runat="server" 
                OnLoggingIn="OnLoggingIn" 
                UserNameLabelText="Email Address:" 
                UserNameRequiredErrorMessage="Email Address.">
            </asp:Login>
        </form>
    </body>
</html>

설명

LoggingIn 이벤트는 사용자가 웹 사이트에서 인증되기 전에 사용자가 로그인 정보를 제출할 때 발생합니다. LoggingIn 이벤트를 사용하여 사용자를 인증하기 전에 필요한 정보를 설정합니다.

개체의 CancelEventArgs 속성을 로 설정 Cancel 하여 이벤트 중에 LoggingIn 로그인 시도를 취소할 true수 있습니다.

LoggingIn 이벤트가 발생한 후 컨트롤은 Login 이벤트를 발생시키고 Authenticate 이벤트를 발생합니다LoggedIn.

이벤트 처리에 대한 자세한 내용은 이벤트 처리 및 발생 을 참조하십시오.

적용 대상

추가 정보