如何获取客户端计算机名称 [英] How to get client machine name

查看:249
本文介绍了如何获取客户端计算机名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何获取客户端计算机名称?我尝试了不同的代码,但我获得了服务器域名。是否有任何代码可以获得正确的客户端机器名称。



我尝试过:



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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆