0

I have a same website in two different languages, with two different domains, one in English and other in Turkish.

Whenever someone accesses my website (www.example.com) I want to redirect that user to www.example.tr if he is accessing that site from TURKEY else to .com if he is accesing my website other that TURKEY

Q: How do i achieve that in asp.net?

Q: What are the options available to achieve this?

Q: Do i have to make changes to IIS or in my CODE?

jazb
  • 5,498
  • 6
  • 37
  • 44
  • @JohnB, the question link you have provided is not answered and hence this question cannot be marked as duplicate of that one. – dj079 Nov 02 '18 at 06:02
  • apologies - wrong link: https://stackoverflow.com/questions/32764989/asp-net-mvc-5-culture-in-route-and-url#32839796 – jazb Nov 02 '18 at 06:05
  • Maybe this helps:https://www.jerriepelser.com/blog/aspnetcore-geo-location-from-ip-address/ – WhoMightThisOneBe Nov 02 '18 at 06:29
  • Is there is anything we can do in IIS?? –  Nov 02 '18 at 08:31
  • no - you can not just do it on IIS, except if you find some kind of extension - search on google to see if anyone exist - To know the country of your user and act, you need to programming.... – Aristos Nov 02 '18 at 08:53

1 Answers1

0

You can use ip geolocation service like "ipstack.com" to find the location of the visitor: ipstack.com example for the Standard Lookup Endpoint using jQuery.ajax. (First register in free Plan and get your API Access Key)

// set endpoint and your access key
var ip = '134.201.250.155'
var access_key = 'YOUR_ACCESS_KEY';

// get the API result via jQuery.ajax
$.ajax({
    url: 'https://api.ipstack.com/' + ip + '?access_key=' + access_key,   
    dataType: 'jsonp',
    success: function(json) {

        // output the "capital" object inside "location"
        alert(json.location.capital);

    }
});

Now based on the answer you received, you can redirect the user to the website you want without any change in IIS.

if (countryCode == "Turkey")
  response.redirect("www.yoursite.tr");
else
  response.redirect("www.yoursite.com");
Shahram Vafadar
  • 194
  • 1
  • 7