本文介绍了如何在WAN上获取客户端系统名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何使用带有vb.net的asp.net获取系统名称
我正在使用这个.
它在Lan上工作正常,但在WAN上却给了我客户端Ip而不是客户端系统名称
请帮助
暗淡的SystemName作为字符串= MachineName(Request.UserHostAddress)
How can i Get system name using asp.net with vb.net
I am using this .
Its working fine on Lan but on WAN it gives me client Ip Instead of Client system Name
Kindly Help
Dim SystemName As String = MachineName(Request.UserHostAddress)
Public Shared Function MachineName(ByVal clientIP As String) As String
Try
Dim hostEntry = System.Net.Dns.GetHostEntry(clientIP)
Return hostEntry.HostName
Catch ex As Exception
End Try
推荐答案
<br />
System.Net.Dns.GetHostEntry
仅在可以访问域DNS服务器的局域网中工作.
will only work in a lan which has access to the domain DNS server.
string sHostName = System.Net.Dns.GetHostName();
System.Net.IPHostEntry ipE =System.Net.Dns.GetHostEntry(sHostName);
System.Net.IPAddress[] IpA = ipE.AddressList;
用于IP地址使用IpA [0] .ToString()
对于主机名,请使用sHostName
希望对您有帮助
for Ip address use IpA[0].ToString()
for Hostname use sHostName
hope it will helps
这篇关于如何在WAN上获取客户端系统名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!