如何在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
答
尝试使用Request.ServerVariables["REMOTE_HOST"]
Try usingRequest.ServerVariables["REMOTE_HOST"]
<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