手机
当前位置:查字典教程网 >编程开发 >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地址示例】相关文章:

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

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

asp.net datalist绑定数据后可以上移下移实现示例

.net数据库连接池配置技巧(默认值)

asp.net连接数据库读取数据示例分享

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

ASP.NET使用gridview获取当前行的索引值

viewstate和datatable动态录入数据示例

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

一个ASP.NET获取用户IP地址公共类

精品推荐
分类导航