FormsAuthenticationModule Sınıf

Tanım

Form kimlik doğrulaması etkinleştirildiğinde bir ASP.NET uygulaması için kullanıcının kimliğini ayarlar. Bu sınıf devralınamaz.

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
Devralma
FormsAuthenticationModule
Uygulamalar

Örnekler

Aşağıdaki örnek, geçerli HttpContext özelliğini özel IPrincipal bir nesneye ayarlamak User için FormsAuthentication_OnAuthenticate olayını kullanır.

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

Açıklamalar

, FormsAuthenticationModule kimlik HttpContext.User doğrulaması uygulamanın yapılandırma dosyasının authentication ModeÖğesi (ASP.NET Ayarlar Şeması) öğesinde olarak ayarlandığında Forms geçerli isteğin kullanıcı kimliğini temsil eden bir IPrincipal nesneye ayarlar.

, FormsAuthenticationModule geçerli HttpContextözelliği için User özel IPrincipal bir nesne sağlamanıza olanak tanıyan bir Authenticate olayı kullanıma sunar. Olaya Authenticate , ASP.NET uygulamanız için Global.asax dosyasında FormsAuthentication_OnAuthenticate adlı bir alt yordam belirtilerek erişilir.

Not

IIS 7.0'da WindowsAuthenticationModule ile kullanmak FormsAuthenticationModule desteklenmez. Tümleşik modlardaki uyumluluk sorunları hakkında daha fazla bilgi için bkz. ASP.NET Uygulamasını IIS 6.0'dan IIS 7.0'a taşıma.

Oluşturucular

FormsAuthenticationModule()

FormsAuthenticationModule sınıfının yeni bir örneğini başlatır.

Yöntemler

Dispose()

tarafından FormsAuthenticationModulekullanılan bellek dışındaki tüm kaynakları serbest bırakır.

Equals(Object)

Belirtilen nesnenin geçerli nesneye eşit olup olmadığını belirler.

(Devralındığı yer: Object)
GetHashCode()

Varsayılan karma işlevi işlevi görür.

(Devralındığı yer: Object)
GetType()

Type Geçerli örneğini alır.

(Devralındığı yer: Object)
Init(HttpApplication)

FormsAuthenticationModule Nesnesini başlatır.

MemberwiseClone()

Geçerli Objectöğesinin sığ bir kopyasını oluşturur.

(Devralındığı yer: Object)
ToString()

Geçerli nesneyi temsil eden dizeyi döndürür.

(Devralındığı yer: Object)

Ekinlikler

Authenticate

Uygulama geçerli isteğin kimliğini doğruladığında gerçekleşir.

Şunlara uygulanır

Ayrıca bkz.