您现在的位置是:网站首页> 编程资料编程资料
.net获取本机公网IP地址示例_实用技巧_
2023-05-24
393人已围观
简介 .net获取本机公网IP地址示例_实用技巧_
代码很简单,直接看代码
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, @"\[(?
return !string.IsNullOrEmpty(ip) ? ip : null;
}
catch (Exception ex)
{
return ex.Message;
}
}
}
}
}
相关内容
- Repeater控件与PagedDataSource结合实现分页功能_实用技巧_
- Repeater控件实现编辑、更新、删除等操作示例代码_实用技巧_
- Repeater怎么实现多行间隔显示分隔符_实用技巧_
- Repeater中嵌套Repeater的示例介绍_实用技巧_
- web.config配置连接字符串的方法_实用技巧_
- ASP.NET 程序中删除文件夹导致session失效问题的解决办法分享_实用技巧_
- asp.net生成缩略图示例方法分享_实用技巧_
- asp.net 操作cookie的简单实例_实用技巧_
- asp.net数据绑定DataBind使用方法_实用技巧_
- Asp.net 后台添加CSS、JS、Meta标签的方法_实用技巧_
