User details in authenticated page

N

NWx

Hi,

I implement forms authentication, and once authenticated, I want to display
user name in a control.
I created a user control, placed on header of every page, and it contains a
label control I want to use to display username of currently logged user.
Do I have this info available in every page? How?

Thank you.
 
J

Joe Kaplan \(MVP - ADSI\)

If your forms authentication is designed properly, then the HttpContext.User
property contains an IPrincipal object with an Identity property whose Name
property should be the name of the user. Thus you should be able to do:

Page.User.Identity.Name or Context.User.Identity.Name to get the user's name
from wherever in your code.

Joe K.
 

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

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top