I am using this script to get User’s Client IP:
<script type="text/javascript" src="http://geoiplookup.wikimedia.org/"></script>
I can get the IP using JavaScript as Geo.IP, but I need to get it in code behind on button click.
Something like:
protected void Button1_Click(object sender, EventArgs e)
{
string IP = string.Empty;
// IP = ???
// Validation code
}
Any ideas?
Thanks in advance…
If you really can’t use server variables, or if you need the geo information as well as the IP, you’ll need something like the following:
This puts the JSON equivalent of the Geo object in your geoiplookup reference
into an ASP.NET hidden field.
Then, on the server, you can access it like: