Take the 2-minute tour ×

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?

share|improve this question
add comment

2 Answers

To get the UserName of the authenticated user:

share|improve this answer
it returns a empty string. –  Luca Romagnoli Feb 10 '11 at 18:39
Are you sure you have the Forms Authentication setup correctly in the web.config file? What does this return 'this.Context.User.Identity.IsAuthenticated' –  Matt Feb 10 '11 at 18:44
@Luca Romagnoli can you post your web.config file? or at least the authentication section and any authorization sections you have? –  Matt Feb 10 '11 at 18:50
@Luca: An empty string (typically) means you are an unauthenticated entity. –  Jaroslav Jandek Feb 10 '11 at 18:56
add comment

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.

share|improve this answer
add comment

Your Answer


