This article mainly introduces the method of obtaining the IP address of the local public network, using the ip138 data, we refer to the use of it.
The code is simple, look directly at the code Code as follows: using System; Using System.Net; Using System.Text.RegularExpressions; namespace Keleyi.com { public class Getinternetip { Public static string GetIP () { using (var webClient = new W Ebclient ()) { try { var temp = webclient.downloadstring ("http://iframe.ip138.com/ic.asp"); var IP = regex.match (temp, @ "[<IP>D+.D+.D+.D +)]"). groups["IP". Value; return!string. IsNullOrEmpty (IP)? Ip:null; &N Bsp catch (Exception ex) { & nbsp return ex. message; } } }}