How to get the user name after FormAuthentication

Discussion in 'ASP .Net' started by Vivian, Sep 8, 2006.

  1. Vivian

    Vivian Guest

    hi,

    I'm new to .aspx and want to ask a question about FormAuthentication.
    I've created a login page and a default page, it works well in the login
    page and can redirect to the default page. The problem is I want to get the
    login name in the default page, what function should I use?

    Thanks in advance.

    Vivian
     
    Vivian, Sep 8, 2006
    #1
    1. Advertising

  2. Vivian

    Tim_Mac Guest

    hi Vivian,
    User.Identity.Name will give you the username of the current user. this is
    the generic 'Identity' object, which provides a basic set of information for
    all the authentication types.

    if your code is outside a code-behind file (i.e. outside a Page context),
    you can use HttpContext.Current.User.Identiy.Name to get the same
    information.

    hope this helps
    tim



    "Vivian" <> wrote in message
    news:...
    > hi,
    >
    > I'm new to .aspx and want to ask a question about FormAuthentication.
    > I've created a login page and a default page, it works well in the login
    > page and can redirect to the default page. The problem is I want to get
    > the login name in the default page, what function should I use?
    >
    > Thanks in advance.
    >
    > Vivian
    >
     
    Tim_Mac, Sep 8, 2006
    #2
    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. tfs
    Replies:
    1
    Views:
    434
  2. T-Bone
    Replies:
    1
    Views:
    365
    SparvHok
    Nov 24, 2004
  3. Pradeep Sabharwal

    Need help in FrameBased FormAuthentication

    Pradeep Sabharwal, Dec 10, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    407
    Pradeep Sabharwal
    Dec 10, 2004
  4. Jamie  Pollard
    Replies:
    4
    Views:
    5,522
    Jamie Pollard
    Jul 15, 2005
  5. Jamie  Pollard

    Storing Role And User Id in UserData of FormAuthentication

    Jamie Pollard, Jul 14, 2005, in forum: ASP .Net Security
    Replies:
    3
    Views:
    134
    Jamie Pollard
    Jul 15, 2005
Loading...

Share This Page