在asp.net中怎么获取客户端ip 地区

来源:百度知道 编辑:UC知道 时间:2024/06/01 11:03:41
现在能获取ip地址,但是怎么获取“地区”呀!
如:IP为(123.116.122.15),所在地:北京市海淀区
现在我想得到“北京市海淀区”,怎么得到呀!
我现在是想获得客户端的地区,怎么通过ip地址得到地区呀!写在js脚本里,在每个页面调用

看看这个能不能满足你的需求,希望能帮到你,呵呵。

这个就是你要求的啊,看看吧。

http://hi.baidu.com/zhxhdean/blog/item/e82c24def2e4a25fccbf1af7.html

//检查本机IP地址
listBox1.Items.Clear();
IPAddress[] AddressList = Dns.GetHostByName(Dns.GetHostName()).AddressList;
if (AddressList.Length < 1)
{
listBox1.Items.Add("无IP");
}

else
{
for (int i = 0; i < AddressList.Length; i++)
{
listBox1.Items.Add(AddressList[i].ToString());
}
listBox1.SelectedIndex = 0;
btnStart.Enabled = true;
}