0

因为我要创建维护请求页面,所以任何员工都可以在没有互联网的情况下从我们的本地网络使用这个页面,我想获取提出请求的计算机名称和 Ip,

我搜索并阅读了这一点,但如果我得到的大多数是:如何获取互联网 IP 或主机名和 IP,但我的问题是“如何在 Asp.Net 中获取网络计算机名称和网络 IP“非互联网 IP” “??

我发现的一些关于 Internet Ip 和主机信息的信息是:

using System.Net;
//Get the Host name:

    string strHostName = string.Empty;
    strHostName = Dns.GetHostName();

    // Then using host name, get the IP address list..
    IPHostEntry ipEntry = Dns.GetHostByName(strHostName);
    //Get the IP address
    IPAddress[] addr = ipEntry.AddressList;
    for (int i = 0; i < addr.Length; i++)
    {
        Response.Write("IP Address {0}: {1} " + i + addr[i].ToString() + ", HostName: " + strHostName);
    } 
    // end of host info.

并以这种方式获取互联网信息:

Response.Write("Your IP Address: " + Request.UserHostAddress + "<BR>");
Response.Write("Your Computer Name: " + System.Net.Dns.GetHostEntry(Request.UserHostAddress).HostName);

那么有什么方法可以获取计算机的本地IP和名称吗?

4

1 回答 1

0

If you have DNS correctly configured to be updated with the names of computers as they connect and disconnect, then you can use reverse resolution to get from the client IP address back to the host name.

If your web site is inside the firewall, the connected user host address will be the internal address and can be resolved. If the site is hosted outside (or possibly in the DMZ) then you will not be able to get the name without requiring the user to provide it - or by running some trusted code on the client to access the local information.

于 2013-01-26T15:17:23.027 回答