Tag:Address acquisition

  • Method of obtaining IP address by. Net

    Time:2020-3-15

    Get native IP 2. Get the IP address of the web client /// <summary> ///Get IPv4 address /// </summary> /// <returns> </returns> public static string GetIP4Address(HttpRequest request = null) { Func<IPAddress, bool> f = e => e.AddressFamily.ToString() == “InterNetwork”; IPAddress ipa = Dns.GetHostAddresses((request ?? HttpContext.Current.Request).UserHostAddress).FirstOrDefault(f) ?? Dns.GetHostAddresses(Dns.GetHostName()).FirstOrDefault(f); if (ipa != null) { return ipa.ToString(); } […]