FormsAuthenticationEventHandler Temsilci
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
bir öğesinin FormsAuthentication_OnAuthenticate olayını FormsAuthenticationModuleişleyen yöntemi temsil eder.
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)
Parametreler
- sender
- Object
Olayın kaynağı.
FormsAuthenticationEventArgs Olay verilerini içeren bir.
Örnekler
Aşağıdaki kod örneği, FormsAuthentication_OnAuthenticate olayını kullanarak geçerlinin User özelliğini özel HttpContextbir GenericPrincipal nesnesine ayarlarIdentity.
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
Temsilci FormsAuthenticationEventHandler , sınıfın Authenticate olayı FormsAuthenticationModule için tanımlanır. ASP.NET uygulamanızın Authenticate Global.asax dosyasında FormsAuthenticationModule adlı bir alt yordam belirterek sınıfının olayına erişebilirsiniz. Olay Authenticate , olay sırasında AuthenticateRequest oluşturulur.
, FormsAuthenticationModule geçerli FormsAuthenticationEventArgs kullanarak bir HttpContext nesne oluşturur ve FormsAuthentication_OnAuthenticate olayına geçirir.
geçerli User özelliğini FormsAuthenticationEventArgs özel bir nesne olarak ayarlamak User için HttpContext olayına sağlanan nesnenin özelliğini kullanabilirsinizIPrincipal. User olayı sırasında özelliği için bir değer belirtmezseniz, tanımlama bilgisinde veya URL'de form kimlik doğrulama bileti tarafından sağlanan kimlik kullanılır.
FormsAuthentication_OnAuthenticate olayı yalnızca kimlik doğrulaması Mode olarak ayarlandığında Forms ve FormsAuthenticationModule uygulama için etkin bir HTTP modülü olduğunda oluşturulur.
Uzantı Metotları
| Name | Description |
|---|---|
| GetMethodInfo(Delegate) |
Belirtilen temsilci tarafından temsil edilen yöntemi temsil eden bir nesnesi alır. |