I have a bootstrap enabled website two divs DivOne and DivTwo.
I want to display DivTwo if the country is India. I want to display DivOne if the country is anything other than India.
How can I implement this in ASP.NET/HTML/JavaScript?
This is what I have so far in C#:
public string LocalIPAddress()
{
IPHostEntry host;
string localIP = "";
host = Dns.GetHostEntry(Dns.GetHostName());
foreach (IPAddress ip in host.AddressList)
{
if (ip.AddressFamily == AddressFamily.InterNetwork)
{
localIP = ip.ToString();
break;
}
}
return localIP;
}
I also want the same code to run in mobile sites as well.
One small addition. I would rather prefer an online service that takes an IP address and gives the country name rather than installing a database on my server. Thanks!