如何获取IP位置(城市,地区,国家/地区,Isp) [英] How to get ip location( city, Region,Country,Isp)

查看:65
本文介绍了如何获取IP位置(城市,地区,国家/地区,Isp)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用此代码...



1

i am using this code...



1

public DataTable getLocation(string user_ip)
        {
            WebRequest webr = WebRequest.Create("http://freegeoip.appspot.com/xml/" + user_ip);
            WebProxy px = new WebProxy("http://freegeoip.appspot.com/xml/" + user_ip, true);
            webr.Proxy = px;
            webr.Timeout = 4000;
            try
            {
                WebResponse we = webr.GetResponse();
                XmlTextReader xt = new XmlTextReader(we.GetResponseStream());
                DataSet ds = new DataSet();
                ds.ReadXml(xt);
                 return  ds.Tables [0];
            }
            catch
            {
                return null;

            }
        }



2



2

string hostName = Dns.GetHostName();
            Response.Write("Hostname : " + hostName + "<br/>");
            IPHostEntry local= Dns .GetHostByName(hostName);
            foreach (IPAddress ipaddress in local.AddressList)
            {
                Response.Write("Hostname : " + ipaddress.ToString () + "<br/>");
            }




任何其他用于IP信息的代码....(位置,城市,地区,国家/地区,Isp)
帮帮我...谢谢




Any Other code .... for ip information( location,city, Region,Country,Isp)
help me... Thanks

推荐答案

您没有提到此代码有什么问题.它会给出任何错误吗?

如果对您不起作用,则有很多此类服务可用.
检查一下: http://www.ip2location.com/free.asp [ http://www.google.co.in/#sclient=psy&num=10&hl=zh-CN&q=location+from+ip&aq=f& aqi =& aql =& oq =& pbx = 1& fp = ae1ee85e922f7961 [
You didn''t mention what problem you have with this code. Does it give any error?

There are lot of such services available if it is not working for you.
Check this out: http://www.ip2location.com/free.asp[^]

Also check the Google search link:
http://www.google.co.in/#sclient=psy&num=10&hl=en&q=location+from+ip&aq=f&aqi=&aql=&oq=&pbx=1&fp=ae1ee85e922f7961[^]




使用此
[
Hi,

Use this one This[^]


umesh


这篇关于如何获取IP位置(城市,地区,国家/地区,Isp)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆