你的位置:首页 > 软件开发 > ASP.net > .net获取本机公网IP代码

.net获取本机公网IP代码

发布时间:2015-12-31 09:00:10
using System;using System.Net;using System.Text.RegularExpressions;namespace Keleyi.Com{ public class GetInternetIP { public static str ...
using System;using System.Net;using System.Text.RegularExpressions;namespace Keleyi.Com{  public class GetInternetIP  {    public static get='_blank'>string GetIP()    {      using (var webClient = new WebClient())      {        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;        }        catch (Exception ex)        {          return ex.Message;        }      }    }  }}

 

海外公司注册、海外银行开户、跨境平台代入驻、VAT、EPR等知识和在线办理:https://www.xlkjsw.com

原标题:.net获取本机公网IP代码

关键词:.NET

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。