title: safe way to get the country from an IP Address in ASP.net MVC
body: <p>I am working on multi language website , I can get Users IP Address, the problem is that I am looking for a very safe and trustworthy way to get IP and give me the country code , I want users confront their own language page while entering to my website, I have using once before, but it stops providing the service .  Does any one have any idea how to do it? here is my code , and I really appreciate any help. I am looking for a real trustworthy one , google or some other API or even any code suggestion</p>
  
  <pre><code>    public async Task&lt;ActionResult&gt; Index()
      {
  
  
          try
          {
              string userIpAddress = this.Request.UserHostAddress;
              var client = new HttpClient
              {
                  BaseAddress = new Uri("https:// `I need API HERE` ")
              };
  
              var response = await client.GetAsync(userIpAddress);
  
              var content = await response.Content.ReadAsStringAsync();
  
              var result = (Response)new XmlSerializer(typeof(Response)).Deserialize(new StringReader(content));
              var country_name = result.CountryName;
              var country_code = result.CountryCode;
              TempData["Country_code"] = country_code;
              TempData["Country_name"] = country_name;
  
              if (country_code == "FR")
              {
                  return RedirectToAction("fr", "Home");
              }
              else if (country_code == "JP")
              {
                  return RedirectToAction("jp", "Home");
              }
              else if (country_code == "DE")
              {
                  return RedirectToAction("de", "Home");
              }
  
              else if (country_code == "NL")
              {
                  return RedirectToAction("nl", "Home");
              }
              else if (country_code == "CN")
              {
                  return RedirectToAction("cn", "Home");
              }
              else if (country_code == "DK")
              {
                  return RedirectToAction("dk", "Home");
              }
              else if (country_code == "RU")
              {
                  return RedirectToAction("ru", "Home");
              }
              else
              {
                  return RedirectToAction("en", "Home");
  
              }
  
  
          }
          catch
          {
              return RedirectToAction("en", "Home");
          }
  
  
      }
  </code></pre>