다음을 통해 공유


FormsAuthenticationModule 클래스

정의

양식 인증을 사용하는 경우 ASP.NET 애플리케이션에 대한 사용자의 ID를 설정합니다. 이 클래스는 상속할 수 없습니다.

public ref class FormsAuthenticationModule sealed : System::Web::IHttpModule
public sealed class FormsAuthenticationModule : System.Web.IHttpModule
type FormsAuthenticationModule = class
    interface IHttpModule
Public NotInheritable Class FormsAuthenticationModule
Implements IHttpModule
상속
FormsAuthenticationModule
구현

예제

다음은 FormsAuthentication_OnAuthenticate 이벤트를 사용하여 현재 HttpContext 속성을 사용자 지정 IPrincipal 개체로 설정하는 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

설명

FormsAuthenticationModule 애플리케이션 구성 파일의 인증 요소(ASP.NET 설정 스키마) 요소에서 인증 Mode 을 설정할 Forms 때 현재 요청의 사용자 ID를 나타내는 개체로 현재 HttpContext.User 속성을 IPrincipal 설정합니다.

현재 FormsAuthenticationModule 속성HttpContextAuthenticate 대한 User 사용자 지정 IPrincipal 개체를 제공할 수 있는 이벤트를 노출합니다. 이 Authenticate 이벤트는 ASP.NET 애플리케이션의 Global.asax 파일에 FormsAuthentication_OnAuthenticate 이라는 서브루틴을 지정하여 액세스합니다.

메모

IIS 7.0에서는 with FormsAuthenticationModuleWindowsAuthenticationModule 사용하는 것이 지원되지 않습니다. 통합 모드의 호환성 문제에 대한 자세한 내용은 IIS 6.0에서 IIS 7.0으로 ASP.NET 애플리케이션 이동을 참조하세요.

생성자

Name Description
FormsAuthenticationModule()

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

메서드

Name Description
Dispose()

에서 사용하는 메모리를 제외한 모든 리소스를 FormsAuthenticationModule해제합니다.

Equals(Object)

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

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

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

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

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

(다음에서 상속됨 Object)
Init(HttpApplication)

초기화는 FormsAuthenticationModule 개체입니다.

MemberwiseClone()

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

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

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

(다음에서 상속됨 Object)

이벤트

Name Description
Authenticate

애플리케이션이 현재 요청을 인증할 때 발생합니다.

적용 대상

추가 정보