FormsAuthenticationEventArgs 클래스

정의

FormsAuthentication_OnAuthenticate 이벤트에 대한 데이터를 제공합니다. 이 클래스는 상속될 수 없습니다.

public ref class FormsAuthenticationEventArgs sealed : EventArgs
public sealed class FormsAuthenticationEventArgs : EventArgs
type FormsAuthenticationEventArgs = class
    inherit EventArgs
Public NotInheritable Class FormsAuthenticationEventArgs
Inherits EventArgs
상속
FormsAuthenticationEventArgs

예제

다음 코드 예제에서는 FormsAuthentication_OnAuthenticate 이벤트가 설정는 User 속성이 현재 HttpContextGenericPrincipal 개체를 사용자 지정 Identity합니다.

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.");
  }
}
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

설명

합니다 FormsAuthenticationEventArgs 클래스 이벤트 값을 제공 하는 데 사용 됩니다 합니다 FormsAuthentication_OnAuthenticate 이벤트 및 현재 요청에 대 한 사용자 지정 id를 지정할 수 있도록 합니다.

FormsAuthenticationModule 생성을 FormsAuthenticationEventArgs 현재 사용 하 여 개체 HttpContext 에 전달 합니다 FormsAuthentication_OnAuthenticate 이벤트.

사용할 수는 User 속성을 설정 합니다 User 속성이 현재 HttpContext 사용자 지정 IPrincipal 개체입니다.

에 대 한 값을 지정 하지 않는 경우는 User 중에 속성을 FormsAuthentication_OnAuthenticate 이벤트 폼 인증 티켓 쿠키 또는 URL에서 제공 하는 id가 사용 됩니다.

합니다 FormsAuthentication_OnAuthenticate 이벤트는만 있을 때 발생 인증 Mode 로 설정 되어 FormsFormsAuthenticationModule 하는 애플리케이션에 대 한 활성 HTTP 모듈입니다.

생성자

FormsAuthenticationEventArgs(HttpContext)

FormsAuthenticationEventArgs 클래스의 새 인스턴스를 초기화합니다.

속성

Context

현재 HTTP 요청에 대한 HttpContext 개체를 가져옵니다.

User

요청과 연결될 IPrincipal 개체를 가져오거나 설정합니다.

메서드

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

적용 대상

추가 정보