FormsAuthenticationEventArgsとは? わかりやすく解説

FormsAuthenticationEventArgs クラス

FormsAuthentication_OnAuthenticate イベントのデータを提供します。このクラスは継承できません。

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

Public NotInheritable Class
 FormsAuthenticationEventArgs
    Inherits EventArgs
Dim instance As FormsAuthenticationEventArgs
public sealed class FormsAuthenticationEventArgs
 : EventArgs
public ref class FormsAuthenticationEventArgs
 sealed : public EventArgs
public final class FormsAuthenticationEventArgs
 extends EventArgs
public final class FormsAuthenticationEventArgs
 extends EventArgs
解説解説

FormsAuthenticationEventArgs クラスは FormsAuthentication_OnAuthenticate イベントにイベント値を指定し、現在の要求に対するカスタム ID を指定できるようにするために使用されます。

FormsAuthenticationModule は、現在の HttpContext を使用して FormsAuthenticationEventArgs オブジェクトを生成し、それを FormsAuthentication_OnAuthenticate イベントに渡します。

User プロパティを使用して、現在の HttpContext の User プロパティを、カスタムの IPrincipal オブジェクトに設定できます。

FormsAuthentication_OnAuthenticate イベント中に User プロパティ値を指定しない場合、フォーム認証チケットによって提供される Cookie または URL 内の ID が使用されます。

FormsAuthentication_OnAuthenticate イベントは、認証の Mode が Forms に設定され、FormsAuthenticationModule がアプリケーションのアクティブ HTTP モジュールである場合にのみ生成されます。

使用例使用例

FormsAuthentication_OnAuthenticate イベントを使用して、現在の HttpContext の User プロパティに、カスタム 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.");
  }
}
.NET Framework のセキュリティ.NET Framework のセキュリティ
継承階層継承階層
System.Object
   System.EventArgs
    System.Web.Security.FormsAuthenticationEventArgs
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

FormsAuthenticationEventArgs コンストラクタ

FormsAuthenticationEventArgs クラスの新しいインスタンスを初期化します。

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

Public Sub New ( _
    context As HttpContext _
)
Dim context As HttpContext

Dim instance As New FormsAuthenticationEventArgs(context)
public FormsAuthenticationEventArgs (
    HttpContext context
)
public:
FormsAuthenticationEventArgs (
    HttpContext^ context
)
public FormsAuthenticationEventArgs (
    HttpContext context
)
public function FormsAuthenticationEventArgs
 (
    context : HttpContext
)

パラメータ

context

イベントのコンテキスト。

解説解説

FormsAuthenticationModule は、Context プロパティ値として提供される context を使用して FormsAuthenticationEventArgs オブジェクトを構築します。そして、FormsAuthenticationEventArgs オブジェクトを FormsAuthentication_OnAuthenticate イベントに渡します。

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
FormsAuthenticationEventArgs クラス
FormsAuthenticationEventArgs メンバ
System.Web.Security 名前空間
その他の技術情報
フォーム認証プロバイダ

FormsAuthenticationEventArgs プロパティ


パブリック プロパティパブリック プロパティ

参照参照

関連項目

FormsAuthenticationEventArgs クラス
System.Web.Security 名前空間

その他の技術情報

フォーム認証プロバイダ

FormsAuthenticationEventArgs メソッド


FormsAuthenticationEventArgs メンバ

FormsAuthentication_OnAuthenticate イベントのデータを提供します。このクラスは継承できません。

FormsAuthenticationEventArgs データ型で公開されるメンバを以下の表に示します。


パブリック コンストラクタパブリック コンストラクタ
  名前 説明
パブリック メソッド FormsAuthenticationEventArgs FormsAuthenticationEventArgs クラスの新しいインスタンスを初期化します。
パブリック プロパティパブリック プロパティ
パブリック メソッドパブリック メソッド
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

FormsAuthenticationEventArgs クラス
System.Web.Security 名前空間

その他の技術情報

フォーム認証プロバイダ



英和和英テキスト翻訳

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

辞書ショートカット

すべての辞書の索引

「FormsAuthenticationEventArgs」の関連用語

FormsAuthenticationEventArgsのお隣キーワード
検索ランキング

   

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



FormsAuthenticationEventArgsのページの著作権

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

©2026 GRAS Group, Inc.RSS