如何使用IP地址获取国家/地区名称 [英] how to get country name using ip address
本文介绍了如何使用IP地址获取国家/地区名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
// 客户端通过HTTP代理或负载均衡器连接到Web服务器
字符串 ip = HttpContext.Current.Request.ServerVariables [ HTTP_X_FORWARDED_FOR];
if ( string .IsNullOrEmpty(ip))
{
ip = HttpContext.Current.Request.ServerVariables [ REMOTE_ADDR];
}
返回 ip;
使用此代码获取IP地址如何通过使用此IP地址获取国家/地区名称请帮助我
解决方案
谷歌搜索返回以下
极端优化#1.1:将IP地址映射到国家/地区代码。 [ ^ ]
如何确定IP地址是否属于某个国家/地区 [ ^ 一>
Hi,
//client connecting to a web server through an HTTP proxy or load balancer
String ip = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (string.IsNullOrEmpty(ip))
{
ip = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
}
return ip;
am getting the ip address using this code how can i get country name by using this ip address please help me
解决方案
Google search returned following
Extreme Optimization #1.1: Mapping IP addresses to country codes.[^]
how to determine if an ip address belongs to a country[^]
这篇关于如何使用IP地址获取国家/地区名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文