Click here to Skip to main content
14,700,041 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.....
Updated 11-Sep-12 3:43am

Mohamed Mitwalli 11-Sep-12 8:29am
Prasad_Kulkarni 11-Sep-12 8:31am
Thank you Mohamed!
write this code whereever u needed

string ipAddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
            if (string.IsNullOrEmpty(ipAddress))
                ipAddress = Request.ServerVariables["REMOTE_ADDR"];
                //ipAddress = "";
            string APIKey = "ur key";
            string url = string.Format("{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>();
  s = locations[0].CountryName;

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

Get API key from this site[^]
in the same way we can get more details if u need it let me know

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900