Login.Authenticate イベント

定義

ユーザーが認証されたときに発生します。

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

イベントの種類

次のコード例では、 イベントを Authenticate 使用してサイト固有のカスタム認証コードを呼び出します。

<%@ 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">
private bool SiteSpecificAuthenticationMethod(string UserName, string Password)
{
    // Insert code that implements a site-specific custom 
    // authentication method here.
    //
    // This example implementation always returns false.
    return false;
}

private void OnAuthenticate(object sender, AuthenticateEventArgs e)
{
    bool Authenticated = false;
    Authenticated = SiteSpecificAuthenticationMethod(Login1.UserName, Login1.Password);

    e.Authenticated = Authenticated;
}

</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"
                OnAuthenticate="OnAuthenticate">
            </asp:Login>
        </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">
Function SiteSpecificAuthenticationMethod(ByVal UserName As String, ByVal Password As String) As Boolean
    ' Insert code that implements a site-specific custom 
    ' authentication method here.
    '
    ' This example implementation always returns false.
    Return False
End Function

Sub OnAuthenticate(ByVal sender As Object, ByVal e As AuthenticateEventArgs)
    Dim Authenticated As Boolean
    Authenticated = SiteSpecificAuthenticationMethod(Login1.UserName, Login1.Password)

    e.Authenticated = Authenticated
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"
                OnAuthenticate="OnAuthenticate">
            </asp:Login>

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

注釈

イベントは Authenticate 、ユーザーが コントロールを Login 使用して Web サイトにログインするときに発生します。 カスタム認証スキームでは、 イベントを Authenticate 使用してユーザーを認証できます。

注意

ユーザーがコントロールを Login 使用して Web サイトにログインすると、ビューステート内のすべてのデータとすべての投稿データが失われます。 ビューステートに依存する Authenticate イベントではアクションを実行しないでください。

イベントの処理の詳細については、「処理とイベントの発生」を参照してください。

注意 (継承者)

カスタム認証スキームでは、 プロパティを Authenticatedtrue 設定して、ユーザーが認証されたことを示す必要があります。

ユーザーがログイン情報を送信すると、コントロールは最初に Login イベント、次に LoggingInAuthenticate イベント、最後に イベントを LoggedIn 発生させます。

適用対象

こちらもご覧ください