Arianule
Arianule

Reputation: 9053

Detect where website is opened from

Sorry, this may come across as a bit vague but how would go about and displaying a different logo of an organisation based on where the site is opened from. For example, the organisation would want their official South African logo to be displayed when the site is opened in South Africa, and another official logo when it is opened in Kenya or Ghana for example.

Would the site simply have to be hosted in more than one server...can't think of any other possible way?

Upvotes: 0

Views: 126

Answers (3)

Chetan Sharma
Chetan Sharma

Reputation: 332

In a very short, in market so many vendors are there, who are tracking geolocation, One of them is google API.

https://www.googleapis.com/geolocation/v1/geolocate?key=YOUR_API_KEY

You can generate your own API_KEY.

Hope this post will helps you. :)

Upvotes: 0

Gobinath Manokaran
Gobinath Manokaran

Reputation: 56

I would have this as a comment .Since, I don't have enough reputations, I am posting as an answer.

This link would be useful to detect the country and change the logo based on the country in your logic.

Detect/estimate country of a http-request in ASP.NET


Adding the contents of the link, since the link may expire.

You can use one of available web services to match an incoming request to a country.

Otherwise you may decide to grab the MaxMind database file (GeoLite Country), read from this file in your application and perform a match. Thus you will be independent from a third-party service, only pulling regularly updates for the database file.

Also check out similar questions:

Geolocation web service recommendations

Know a good IP address Geolocation Service?

Upvotes: 1

sreejithsdev
sreejithsdev

Reputation: 1210

To find country first you find Ipaddress

string Ipaddress= HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];

Using Ip address you can find location as follows

using (var wc = new WebClient())
{
    string output = wc.DownloadString(String.Format("http://api.hostip.info/?ip={0}&position=true", ipaddress));
}

Output is in XML format and it will contain a countryName tag

Upvotes: 2

Related Questions