Link to home
Start Free TrialLog in
Avatar of bullrout
bullrout

asked on

FormsIdentity & FormsAuthenticationTicket not defined in project -- please help

Hi There,

I am trying to use these properties ( FormsIdentity & FormsAuthenticationTicket ) in my function and I get the error saying they are not defined, I have imported all the namespaces that I thought I needed and it still does not work in my global .asx file.

Sean

Imports System.Web
Imports System.Web.SessionState
Imports System.Security.Principal
Imports System.Security


Sub Application_AuthenticateRequest(ByVal sender As Object, ByVal e As EventArgs)

        If Not (HttpContext.Current.User Is Nothing) Then
            If HttpContext.Current.User.Identity.IsAuthenticated Then
                If TypeOf HttpContext.Current.User.Identity Is FormsIdentity Then
                    Dim id As FormsIdentity = CType(HttpContext.Current.User.Identity, FormsIdentity)
                    Dim ticket As FormsAuthenticationTicket = id.Ticket
                    Dim userData As String = ticket.UserData
                    Dim roles As String = userData.Split(","c)
                    HttpContext.Current.User = New GenericPrincipal(id, roles)
                End If
            End If
        End If
    End Sub
ASKER CERTIFIED SOLUTION
Avatar of DotNetLover_Baan
DotNetLover_Baan

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Timbo87
Timbo87

You'll need to add a reference to System.Web.dll if this is in VS.NET.