C#获取外网IP地址;C#获取所在IP城市地址
来源:互联网 发布:c语言数组怎么用 编辑:程序博客网 时间:2024/05/22 00:30
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;
}
}
{
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;
}
}
}
//表单验证
$(function () {
var ip = $.trim($("#hidLocalIp").val()); // "218.4.255.91";
$.getScript('http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js&ip=' + ip, function (_result) {
if (remote_ip_info.ret == "1") {
$("#hidArea").val(ip + ";" + remote_ip_info.country + ";" + remote_ip_info.province + ";" + remote_ip_info.city + ";" + remote_ip_info.isp + ";");
//alert(ip + ";" + remote_ip_info.country + ";" + remote_ip_info.province + ";" + remote_ip_info.city + ";" + remote_ip_info.isp + ";");
}
});
});
0 0
- C#获取外网IP地址;C#获取所在IP城市地址
- C#根据IP地址获取城市
- C#获取IP地址
- C#获取IP地址
- c# 获取ip地址
- c# 获取IP地址
- C# 获取IP地址
- 获取iP所在地址
- c#获取外网IP地址
- C#获取主机IP地址
- C#获取本地连接IP地址
- C# 获取主机IP地址
- 获取客户端IP地址 C#
- C#获取本地连接IP地址
- C#获取本地IP地址
- C# 获取主机IP地址
- 20170116-C#获取IP地址
- c# 获取本地Ip地址
- ios中SQLite3的基本操作
- 黑马程序员_学前须知之mac常用知识介绍和unix基础指令
- 鼠标滚动 回到顶部
- sgu100-熟悉环境
- 关于字符串的那些事儿
- C#获取外网IP地址;C#获取所在IP城市地址
- sys.argv和raw_input的区别
- 逗B少年搞程序03 简单工厂模式——模式来源于生活而高于生活
- Android无法导入下载好的项目(和Eclipse中已经存在的项目命名一样导致冲突)解决办法
- 游戏架构 云游戏(4)-云主机与vps的对比
- 高效开发Android App的10个建议
- win32通用控件TreeView滚动条自绘
- C语言实现数值转换(十进制转八进制)
- 程序员编程艺术:第三章续、Top K算法问题的实现