다음을 통해 공유


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 이벤트를 사용 하 여 사용자 지정 Identity개체에 GenericPrincipal 현재 HttpContext 속성을 설정 User 합니다.

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를 지정할 수 있도록 하는 데 사용됩니다.

현재 FormsAuthenticationModuleHttpContext 개체를 FormsAuthenticationEventArgs 사용하여 개체를 생성하고 FormsAuthentication_OnAuthenticate 이벤트에 전달합니다.

User 속성을 사용하여 현재 HttpContext 속성을 사용자 지정 IPrincipal 개체로 설정할 User 수 있습니다.

FormsAuthentication_OnAuthenticate 이벤트 중에 속성 값을 User 지정하지 않으면 쿠키 또는 URL의 양식 인증 티켓에서 제공하는 ID가 사용됩니다.

FormsAuthentication_OnAuthenticate 이벤트는 인증 Mode 이 설정 FormsFormsAuthenticationModule 되고 애플리케이션에 대한 활성 HTTP 모듈인 경우에만 발생합니다.

생성자

Name Description
FormsAuthenticationEventArgs(HttpContext)

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

속성

Name Description
Context

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

User

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

메서드

Name Description
Equals(Object)

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

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

기본 해시 함수로 사용됩니다.

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

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

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

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

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

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

(다음에서 상속됨 Object)

적용 대상

추가 정보