在网站上查看访客国家 [英] check visitor country on website

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

问题描述

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

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

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

请帮助.....

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.....

推荐答案

引用:
在Asp.net中从访问者IP查找国家/地区 [ ^ ]
获取访问者IP地址并获取国家/地区详细信息通过ipaddress [ ^ ]

如果您尝试
Refer:
Finding Country from Visitors IP in Asp.net[^]
Get Visitors Ip address and Get Country details by ipaddress[^]

you can get more results if you try this[^]


尝试按IP地址查找国家/地区.请参考
使用IP地址查找国家和城市
http://ipaddressextensions.codeplex.com/
Try to find country by Ip Address. Refer this
Finding Countries and Cities Using IP Address
http://ipaddressextensions.codeplex.com/


在需要的地方编写此代码

write this code whereever u needed

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


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

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