I am working on a site with a custom db (ie. not aspnetdb) and am just creating a quick work around for login functionality.
Everything seems to be working ok accept the value of the cookie is always null during Application_AuthenticateRequest
And here is the AuthenticateRequest functionality: Dim app As HttpApplication = CType(sender, HttpApplication)
Dim cookie As HttpCookie = Response.Cookies(FormsAuthentication.FormsCookieName)
If (cookie IsNot Nothing) Then
Dim encryptedTicket As String = cookie.Value
If (encryptedTicket IsNot Nothing) Then
If (encryptedTicket.Length > 0) Then
Dim ticket As FormsAuthenticationTicket = FormsAuthentication.Decrypt(encryptedTicket)
Dim roles As String() = ticket.UserData.Split(New Char() {","})
Dim identity As FormsIdentity = New FormsIdentity(ticket)
Dim user As System.Security.Principal.GenericPrincipal = New System.Security.Principal.GenericPrincipal(identity, roles)
End If
End If
End If
And here is the login functionality
Dim roles As String = "Admin"
Dim ticket As FormsAuthenticationTicket = New FormsAuthenticationTicket(1, Login1.UserName, DateTime.Now, DateTime.Now.AddMinutes(40), False, roles)
Dim encryptedTicket As String = FormsAuthentication.Encrypt(ticket)
Dim cookie As HttpCookie = New HttpCookie(FormsAuthentication.FormsCookieName)
cookie.Value = encryptedTicket
If (Response.Cookies(FormsAuthentication.FormsCookieName) IsNot Nothing) Then
Response.Cookies.Remove((Response.Cookies(FormsAuthentication.FormsCookieName).Name))
End If
Response.Cookies.Add(cookie)
Response.Redirect(FormsAuthentication.GetRedirectUrl(Login1.UserName, True), True)
Any ideas?