Forms authentication - how to retrieve logged-in username?

Discussion in 'ASP .Net' started by Paul W, Nov 3, 2004.

  1. Paul W

    Paul W Guest

    I've got Forms Authentication up and running. The starting page for the app.
    is default.aspx. I want to display on the top of this form a 'You are logged
    in as Fredxyz' message.

    If the user is a return user and was automatically logged in by a persistent
    auth. cookie, how can I find out the 'username' that he's logged in as?

    Thanks,

    Paul.
     
    Paul W, Nov 3, 2004
    #1
    1. Advertisements

  2. The HttpContext.Current.User.Identity.Name will return the value that has
    been set for the name field. Howevery, this is often just an ID number or
    something else. You can create your own identity class based on the
    IIdentity interface. You can also generate a custom ticket to pass with the
    forms authentication. This has the benefit of having custom data stored in a
    custom data field for the ticket that could be used to store the user's
    name.

    Hope this helps,
    Mark Fitzpatrick
    Microsoft MVP - FrontPage

    "Paul W" <> wrote in message
    news:...
    > I've got Forms Authentication up and running. The starting page for the
    > app. is default.aspx. I want to display on the top of this form a 'You are
    > logged in as Fredxyz' message.
    >
    > If the user is a return user and was automatically logged in by a
    > persistent auth. cookie, how can I find out the 'username' that he's
    > logged in as?
    >
    > Thanks,
    >
    > Paul.
    >
     
    Mark Fitzpatrick, Nov 3, 2004
    #2
    1. Advertisements

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. Brian Henry

    getting username logged in

    Brian Henry, Aug 26, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    1,931
    Brian Henry
    Aug 27, 2003
  2. Eric
    Replies:
    2
    Views:
    1,779
    Tommy
    Feb 13, 2004
  3. John Dalberg
    Replies:
    6
    Views:
    21,400
    John Dalberg
    Apr 18, 2005
  4. keithb
    Replies:
    0
    Views:
    771
    keithb
    Feb 16, 2006
  5. Replies:
    1
    Views:
    1,133
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Apr 12, 2007
  6. ThaYoung1!
    Replies:
    0
    Views:
    244
    ThaYoung1!
    Aug 7, 2003
  7. Lauchlan M

    When exactly are you logged in? (Forms authentication)

    Lauchlan M, Oct 2, 2003, in forum: ASP .Net Security
    Replies:
    2
    Views:
    280
    Lauchlan M
    Oct 2, 2003
  8. Eric
    Replies:
    2
    Views:
    923
Loading...