Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the username in Forms authentication

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?

like image 930
Luca Romagnoli Avatar asked Feb 10 '11 18:02

Luca Romagnoli


People also ask

How is form authentication done?

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.

What is authentication mode forms?

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.

How do I change form authentication in Windows authentication?

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.


1 Answers

To get the UserName of the authenticated user:

HttpContext.Current.User.Identity.Name; 
like image 53
Matt Avatar answered Oct 02 '22 14:10

Matt