我的代码如下:
IPHostEntry GetIPHost = Dns.GetHostEntry(userIP);
List<string> compName = GetIPHost.HostName.ToString().Split('.').ToList();
string computerName = compName.First();
同网段可以获取到,到跨网段就不行了,有跨网段的方法吗?
你这样只能获取服务器本地的IP地址,想要获得访问你站点的客户端地址,参考下面链接
https://www.cnblogs.com/wangfuyou/p/5943620.html