Click here to Skip to main content
15,888,579 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
See more:
C#
i want to get user name of the system but is does not work on server it only run in local host


What I have tried:

i want to get user name of the system but is does not work on server it only run in local host
Posted
Updated 27-May-16 3:15am
Comments
Philippe Mori 27-May-16 9:14am    
Show the code you have tried. Tell us what you expected and what you get. You won't get much help if you don't write good question.
Karthik_Mahalingam 27-May-16 10:10am    
Post your code, is this intranet application?

1 solution

That's because C# code is executed at the Server, not the Client: so when you use C# code to get a host system name, it returns the Server name, not the Client. It appears to work when you run it in development on the local host because the two computers are the same physical machine.
You can try HttpRequest.UserHostName Property (System.Web)[^] but there is a good chance it will just return the IP address.
 
Share this answer
 

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


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