Master Pages with Login Status

  • Thread starter Thread starter cs_in_va
  • Start date Start date
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
 
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
 
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.
 
Back
Top