本文介绍了在网站上查看访客国家的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨.....
我正在一个电子商务网站上.我要展示一些产品在仅印度"展示,而其他产品则在印度之外展示.

因此,我想找出进行此处理的访客国家/地区.

注意:-我不能使用任何数据库.

请帮助.....

hi.....
I am working on an e-commercial website. I to show some product are show in Only India and some different product show out side India.

So I want to find out visitor country for this processing.

Note :- I can''t use any database.

Please help.....

推荐答案



string ipAddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
            if (string.IsNullOrEmpty(ipAddress))
            {
                ipAddress = Request.ServerVariables["REMOTE_ADDR"];
                //ipAddress = "97.96.224.60";
            }

            string APIKey = "ur key";
            string url = string.Format("http://api.ipinfodb.com/v3/ip-city/?key={0}&ip={1}&format=json", APIKey, ipAddress);
            using (WebClient client = new WebClient())
            {
                string json = client.DownloadString(url);
                Location location = new JavaScriptSerializer().Deserialize<location>(json);
                List<location> locations = new List<location>();
                locations.Add(location);
  s = locations[0].CountryName;
}


public class Location
{
    public string CountryName{ get; set; }
}


从此站点获取API密钥
http://ipinfodb.com/ip_location_api.php[^]
同样,如果您需要,我们可以获取更多详细信息,让我知道


Get API key from this site
http://ipinfodb.com/ip_location_api.php[^]
in the same way we can get more details if u need it let me know


这篇关于在网站上查看访客国家的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-25 05:21