469,945 Members | 2,317 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,945 developers. It's quick & easy.

Forms authentication - how to retrieve logged-in username?

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.
Nov 18 '05 #1
1 1942
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

"Paul W" <qq*@qqq.com> wrote in message
news:ee**************@TK2MSFTNGP14.phx.gbl...
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.

Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Lamberti Fabrizio | last post: by
2 posts views Thread by ThatsIT.net.au | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.