Get the username in Forms authentication
46,388
Solution 1
To get the UserName of the authenticated user:
HttpContext.Current.User.Identity.Name;
Solution 2
That's exactly how I do it, I think there might be something wrong with your setup? For example, are you actually logged into the site while your debugging? If not, you need to in order to get a value.
Author by
Luca Romagnoli
Updated on January 23, 2020Comments
-
Luca Romagnoli over 4 years
I'm using Forms authentication.
In Windows Authentication for get the user name of the PC i use:
User.Identity.Name
I need this information also in Forms authentication but
User.Identity.Name
doesn't work.How can I get the User.Identity.Name without using Windows authentication?