WebApplication4.Models.Utilitarios2.GetIPAddress C# (CSharp) Method

GetIPAddress() public static method

Gets the IP address of the current PC
public static GetIPAddress ( ) : IPAddress
return System.Net.IPAddress
        public static IPAddress GetIPAddress()
        {
            String strHostName = Dns.GetHostName();
            IPHostEntry ipEntry = Dns.GetHostEntry(strHostName);
            IPAddress[] addr = ipEntry.AddressList;
            foreach (IPAddress ip in addr)
            {
                if (!ip.IsIPv6LinkLocal)
                {
                    return (ip);
                }
            }
            return addr.Length > 0 ? addr[0] : null;
        }