如何获取客户端计算机名称 [英] How to get client machine name
问题描述
如何获取客户端计算机名称?我尝试了不同的代码,但我获得了服务器域名。是否有任何代码可以获得正确的客户端机器名称。
我尝试过:
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;
返回computer_name [0] .ToString();
}
catch(exception ex)
{
返回string.Empty;
}
}
< blockquote>快速谷歌搜索会告诉你,你无法通过互联网获取客户端的计算机名称。
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;
}
}
A quick google search will have told you that you can't get the client's computer name over the internet.
这篇关于如何获取客户端计算机名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!