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?
Form Authentication is a token-based system. When users log in, they receive a token with user information that is stored in an encrypted cookie. When a user requests an ASP.NET page via the browser, the ASP.NET verifies whether the form authentication token is available.
Forms authentication enables user and password validation for Web applications that do not require Windows authentication. With forms authentication, user information is stored in an external data source, such as a Membership database, or in the configuration file for an application.
To verify/change that settings go to IE > Tools > Internet Options > Security TAB > Custom Level > Scroll it to the end and look for User Authentication options.
To get the UserName of the authenticated user:
HttpContext.Current.User.Identity.Name;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With