Master Pages with Login Status

Discussion in 'ASP .Net' started by cs_in_va, Mar 6, 2008.

  1. cs_in_va

    cs_in_va Guest

    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
     
    cs_in_va, Mar 6, 2008
    #1
    1. Advertising

  2. 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

    "cs_in_va" <> wrote in message
    news:...
    > 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
    >
     
    Mark Fitzpatrick, Mar 7, 2008
    #2
    1. Advertising

  3. 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.

    --
    Paulus E Kurniawan
    http://www.paulusevan.net


    "cs_in_va" wrote:

    > 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
    >
    >
     
    Paulus E Kurniawan, Mar 7, 2008
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Electrified Research
    Replies:
    5
    Views:
    2,502
    =?Utf-8?B?Q293Ym95IChHcmVnb3J5IEEuIEJlYW1lcikgLSBN
    Oct 11, 2005
  2. Doug McCann
    Replies:
    1
    Views:
    1,135
    William Brogden
    Aug 5, 2004
  3. Replies:
    1
    Views:
    3,278
    PeterKellner
    May 16, 2006
  4. Sam
    Replies:
    0
    Views:
    723
  5. Sam
    Replies:
    1
    Views:
    805
Loading...

Share This Page