Click here to Skip to main content
15,895,370 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am getting user name by using the following code:

txtName.Text = Environment.UserName;

I have deployed the code in IIS and while running the application then i am getting
user name as "NETWORK SERVICE" in the textbox instead of logged user name.


Thanks in advance.
Posted

1 solution

Use User.Identity.Name to get Identity/Name of LoggedIn user.

However this is applicable when you are using Windows-Authentication and "Anonymous Authentication" is set to false in IIS.

Have a look at below links for more information on "Windows-Authentication" in Asp.Net.

http://msdn.microsoft.com/en-us/library/907hb5w9.aspx

http://msdn.microsoft.com/en-us/library/ff647076.aspx
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900