Click here to Skip to main content
15,897,371 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How to get the client machine name? I tried different codes, but am getting the Server Domain Name. Is there any code to get correct client machine name.

What I have tried:

public static string GetComputerName()
{
try
{
string[] computer_name = System.Net.Dns.GetHostEntry(HttpContext.Current.Request.ServerVariables["remote_addr"]).HostName.Split(new Char[] { '.' });
String ecname = System.Environment.MachineName;
return computer_name[0].ToString();
}
catch (Exception ex)
{
return string.Empty;
}
}
Posted
Updated 23-May-18 6:15am

1 solution

A quick google search will have told you that you can't get the client's computer name over the internet.
 
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