手机
当前位置:查字典教程网 >编程开发 >asp.net教程 >.net获取本机公网IP地址示例
.net获取本机公网IP地址示例
摘要:代码很简单,直接看代码复制代码代码如下:usingSystem;usingSystem.Net;usingSystem.Text.Regul...

代码很简单,直接看代码

复制代码 代码如下:

using System;

using System.Net;

using System.Text.RegularExpressions;

namespace Keleyi.Com

{

public class GetInternetIP

{

public static 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;

}

}

}

}

}

【.net获取本机公网IP地址示例】相关文章:

asp.net读取excel中的数据并绑定在gridview

asp.net错误页面处理示例分享

ASP.NET取得所有颜色值示例

asp.net 获取指定文件夹下所有子目录及文件(树形)

asp.net中获取远程网页的内容之一(downmoon原创)

viewstate和datatable动态录入数据示例

获取pc电脑和平板物理地址

asp.net获取网站绝对路径案例详解

.net开发人员常犯的错误分析小结

asp.net发送邮件示例分享

精品推荐
分类导航