- IPrinciple, HTTPModules ASP.NET, , , System.Web.Security.FormsAuthenticationModule OnAuthenticate.
, , , , global.asax HTTPModule, Application_AuthenticateRequest. :
Public Sub Application_AuthenticateRequest(ByVal sender As Object, ByVal e As System.EventArgs)
Dim cookieName As String = FormsAuthentication.FormsCookieName
Dim authCookie As HttpCookie = HttpContext.Current.Request.Cookies(FormsAuthentication.FormsCookieName)
If Not IsNothing(authCookie) Then
Dim authTicket As FormsAuthenticationTicket = FormsAuthentication.Decrypt(authCookie.Value)
If IsNothing(authTicket) OrElse authTicket.Expired Then
HttpContext.Current.Response.Redirect(FormsAuthentication.LoginUrl)
Else
Dim id As New FormsIdentity(authTicket)
Dim newUser As New YourCustomUserType(id.Name)
HttpContext.Current.User = newUser
End If
End If
End Sub