Master Pages with Login Status

C

cs_in_va

I'm trying to write a notification button on my master page so if
someone is logged in it will display some text in a label.

But I don't get the user.identity.isauthenticated in my code behind
file. What do I need to import?

Thanks
 
M

Mark Fitzpatrick

Because you're using a masterpage, it's inheriting from a different base
class. Normally, the User.Identity is available in a page since it inherits
from System.Web.UI.Page. That said, what you can do is access it from the
masterpage by doing Page.User.Identity.IsAuthenticated.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - Expression
 
P

Paulus E Kurniawan

In your case, you will have to use:

HttpContext.Current.User.Identity.IsAuthenticated

From an aspx page code-behind, you can use User.Identity.IsAuthenticated
because User is a property of Page class which uses HttpContext object's User
property.

Hope this helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,040
Latest member
papereejit

Latest Threads

Top