Home All Groups Group Topic Archive Search About

How to get the user name after FormAuthentication

Author
8 Sep 2006 8:48 AM
Vivian
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

Author
8 Sep 2006 9:45 AM
Tim_Mac
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



Show quoteHide quote
"Vivian" <wki***@hotmail.com> wrote in message
news:uJkrLOy0GHA.4044@TK2MSFTNGP04.phx.gbl...
> 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
>

Bookmark and Share

Post Thread options