How to get the user name after FormAuthentication

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
 
T

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top