Login.Authenticate イベント
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
ユーザーが認証されたときに発生します。
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 イベントを使用してユーザーを認証できます。
Note
ユーザーが Login コントロールを使用して Web サイトにログインすると、ビューステート内のすべてのデータとすべての投稿データが失われます。 ビュー ステートに依存する Authenticate イベントではアクションを実行しないでください。
イベントの処理の詳細については、「処理とイベントの発生」を参照してください。
注意 (継承者)
カスタム認証スキームでは、 Authenticated プロパティを true に設定して、ユーザーが認証されたことを示す必要があります。
ユーザーがログイン情報を送信すると、 Login コントロールは最初に LoggingIn イベント、次に Authenticate イベント、最後に LoggedIn イベントを発生させます。