Forms authentication - how to retrieve logged-in username?

P

Paul W

I've got Forms Authentication up and running. The starting page for the app.
is default.aspx. I want to display on the top of this form a 'You are logged
in as Fredxyz' message.

If the user is a return user and was automatically logged in by a persistent
auth. cookie, how can I find out the 'username' that he's logged in as?

Thanks,

Paul.
 
M

Mark Fitzpatrick

The HttpContext.Current.User.Identity.Name will return the value that has
been set for the name field. Howevery, this is often just an ID number or
something else. You can create your own identity class based on the
IIdentity interface. You can also generate a custom ticket to pass with the
forms authentication. This has the benefit of having custom data stored in a
custom data field for the ticket that could be used to store the user's
name.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage
 

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

Staff online

Members online

Forum statistics

Threads
473,770
Messages
2,569,586
Members
45,088
Latest member
JeremyMedl

Latest Threads

Top