How to get the user name after FormAuthentication

  • Thread starter Thread starter Vivian
  • Start date Start date
V

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
 
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
 
Back
Top