FormsAuthenticationModule.Authenticate イベントとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > FormsAuthenticationModule.Authenticate イベントの意味・解説 

FormsAuthenticationModule.Authenticate イベント

アプリケーション現在の要求認証するときに発生します

名前空間: System.Web.Security
アセンブリ: System.Web (system.web.dll 内)
構文構文

Public Event Authenticate As
 FormsAuthenticationEventHandler
Dim instance As FormsAuthenticationModule
Dim handler As FormsAuthenticationEventHandler

AddHandler instance.Authenticate, handler
public event FormsAuthenticationEventHandler Authenticate
public:
event FormsAuthenticationEventHandler^ Authenticate {
    void add (FormsAuthenticationEventHandler^ value);
    void remove (FormsAuthenticationEventHandler^ value);
}
/** @event */
public void add_Authenticate (FormsAuthenticationEventHandler
 value)

/** @event */
public void remove_Authenticate (FormsAuthenticationEventHandler
 value)
JScript では、イベント使用できますが、新規に宣言することはできません。
解説解説

Authenticate イベントは、AuthenticateRequest イベント時に生成されます。

FormsAuthenticationModule クラスAuthenticate イベントは、ASP.NET アプリケーションの Global.asax ファイルに、FormsAuthentication_OnAuthenticate というサブルーチン指定することによって処理できます

FormsAuthentication_OnAuthenticate イベント渡した FormsAuthenticationEventArgs の User プロパティ使用して現在の HttpContext の User プロパティを、カスタムの IPrincipal オブジェクト設定できますFormsAuthentication_OnAuthenticate イベント中に User プロパティ値を指定しない場合Cookie または URL 内のフォーム認証チケットによって提供される ID使用されます。

FormsAuthentication_OnAuthenticate イベントは、アプリケーション構成ファイルauthentication 要素 (ASP.NET 設定スキーマ) 要素認証モードForms設定されていて、FormsAuthenticationModuleアプリケーションアクティブHTTP モジュールである場合にのみ発生します

使用例使用例

FormsAuthentication_OnAuthenticate イベント使用して現在の HttpContextUser プロパティカスタム Identity を持つ GenericPrincipal オブジェクト設定するコード例次に示します

Public Sub FormsAuthentication_OnAuthenticate(sender
 As Object, _
                                              args As FormsAuthenticationEventArgs)
  If FormsAuthentication.CookiesSupported Then
    If Not Request.Cookies(FormsAuthentication.FormsCookieName)
 Is Nothing Then
      Try
        Dim ticket As FormsAuthenticationTicket
 = FormsAuthentication.Decrypt( _
          Request.Cookies(FormsAuthentication.FormsCookieName).Value)
        
        args.User = New System.Security.Principal.GenericPrincipal(
 _
          New Samples.AspNet.Security.MyFormsIdentity(ticket),
 _
          New String(0) {})
      Catch e As HttpException
        ' Decrypt method failed.
      End Try
    End If
  Else
      Throw New Exception("Cookieless
 Forms Authentication is not " & _
                            "supported for this application.")
  End If
End Sub
public void FormsAuthentication_OnAuthenticate(object
 sender, FormsAuthenticationEventArgs args)
{
  if (FormsAuthentication.CookiesSupported)
  {
    if (Request.Cookies[FormsAuthentication.FormsCookieName] !=
 null)
    {
      try
      {
        FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(
          Request.Cookies[FormsAuthentication.FormsCookieName].Value);
        
        args.User = new System.Security.Principal.GenericPrincipal(
          new Samples.AspNet.Security.MyFormsIdentity(ticket)
,
          new string[0]);
      }
      catch (Exception e)
      {
        // Decrypt method failed.
      }
    }
  }
  else
  {
    throw new HttpException("Cookieless Forms Authentication
 is not " +
                            "supported for this
 application.");
  }
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
FormsAuthenticationModule クラス
FormsAuthenticationModule メンバ
System.Web.Security 名前空間
その他の技術情報
フォーム認証プロバイダ
Global.asax 構文


このページでは「.NET Framework クラス ライブラリ リファレンス」からFormsAuthenticationModule.Authenticate イベントを検索した結果を表示しています。
Weblioに収録されているすべての辞書からFormsAuthenticationModule.Authenticate イベントを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からFormsAuthenticationModule.Authenticate イベント を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

FormsAuthenticationModule.Authenticate イベントのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



FormsAuthenticationModule.Authenticate イベントのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS