How can you tell is current user is authenticated within an ascx?
From: David C. Adler (dcadler@adlercomputing.com)
Date: 08/20/02
- Next message: Mike Moore [MS]: "Re: Creating a process in ASP.NET and checking TotalProcessorTime"
- Previous message: Paul Clement: "Re: Web forms and Active Directory role-based content"
- Next in thread: Kim Bach Petersen: "Re: How can you tell is current user is authenticated within an ascx?"
- Reply: Kim Bach Petersen: "Re: How can you tell is current user is authenticated within an ascx?"
- Reply: Erymuzuan Mustapa: "Re: How can you tell is current user is authenticated within an ascx?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
From: "David C. Adler" <dcadler@adlercomputing.com> Date: Tue, 20 Aug 2002 12:56:22 -0500
I have a user control that I use for header graphics and navigation. My site
uses forms authentication to authenticate users. I want to dynamically
control the menu layout, plus instace login status, based upon whether the
current user has been authenticated. From within my aspx.vb pages, I use the
following code to determine if the user is authenticated and to get the
current users Name value from the Authentication Ticket.
'Retrieve MemberID from Authentication cookie
Private Function GetMemberID() As Integer
Dim objUserIdentity As FormsIdentity
Dim strMemberID As String
If User.Identity.IsAuthenticated Then
objUserIdentity = User.Identity
strMemberID = objUserIdentity.Name
GetMemberID = CType(Trim(strMemberID), Integer)
Else
GetMemberID = 0
End If
End Function
The function works fine in an aspx.vb page but if I put the same code in an
ascx.vb page, I get an error that says...
Name "User" is not declared and references the following line in my code...
If User.Identity.IsAuthenticated Then
What am I missing here?
I dont want to have to add code to all of my 130+ aspx.vb pages in my site
to control the menu like I want. It seems as though I should be able to do
this from the ascx or ascx.vb code and only have to coe it once.
Thanks in advance for any help you can offer.
Dave Adler
- Next message: Mike Moore [MS]: "Re: Creating a process in ASP.NET and checking TotalProcessorTime"
- Previous message: Paul Clement: "Re: Web forms and Active Directory role-based content"
- Next in thread: Kim Bach Petersen: "Re: How can you tell is current user is authenticated within an ascx?"
- Reply: Kim Bach Petersen: "Re: How can you tell is current user is authenticated within an ascx?"
- Reply: Erymuzuan Mustapa: "Re: How can you tell is current user is authenticated within an ascx?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|