Friday, May 1, 2015

asp.net using host name, get the IP address list

   public static string GetHostIP()
        {
            string hostName = GetHostName();
            string hostIP = "";

            // using host name, get the IP address list..
            IPHostEntry ipEntry = Dns.GetHostEntry(hostName);
            IPAddress[] ipAddress = ipEntry.AddressList;

            for (int i = 0; i < ipAddress.Length; i++)
            {
                hostIP = hostIP + ipAddress[i].ToString();
            }
            return hostIP;
        }

No comments:

Post a Comment