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.
Environment.UserName
is the name of the user under which the IIS application is running. by default this is the NETWORK SERVICE user. If you want the username of the user who is logged in via forms authentication you should look at the Page.User
object .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.