FormsAuthenticationEventHandler 대리자

정의

FormsAuthenticationModuleFormsAuthentication_OnAuthenticate 이벤트를 처리하는 메서드를 나타냅니다.

public delegate void FormsAuthenticationEventHandler(System::Object ^ sender, FormsAuthenticationEventArgs ^ e);
public delegate void FormsAuthenticationEventHandler(object sender, FormsAuthenticationEventArgs e);
type FormsAuthenticationEventHandler = delegate of obj * FormsAuthenticationEventArgs -> unit
Public Delegate Sub FormsAuthenticationEventHandler(sender As Object, e As FormsAuthenticationEventArgs)

매개 변수

sender
Object

이벤트 소스입니다.

e
FormsAuthenticationEventArgs

이벤트 데이터를 포함하는 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

설명

FormsAuthenticationEventHandler 대리자에 대해 정의 된 합니다 Authenticate 이벤트는 FormsAuthenticationModule 클래스. 액세스할 수 있습니다 합니다 Authenticate 의 이벤트를 FormsAuthenticationModule 라는 서브루틴을 지정 하 여 클래스 FormsAuthentication_OnAuthenticate ASP.NET 애플리케이션의 Global.asax 파일에. 합니다 Authenticate 이벤트가 발생 하는 동안는 AuthenticateRequest 이벤트입니다.

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

사용할 수 있습니다는 User 의 속성을 FormsAuthenticationEventArgs 개체가 제공를 FormsAuthentication_OnAuthenticate 이벤트가 설정를 User 속성이 현재 HttpContext 을 사용자 지정 IPrincipal 개체입니다. 에 대 한 값을 지정 하지 않는 경우는 User 중에 속성을 FormsAuthentication_OnAuthenticate 이벤트 폼 인증 티켓 쿠키 또는 URL에서 제공 하는 id가 사용 됩니다.

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

확장 메서드

GetMethodInfo(Delegate)

지정된 대리자가 나타내는 메서드를 나타내는 개체를 가져옵니다.

적용 대상

추가 정보