Click here to Skip to main content
15,902,189 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Every one,
In my project I want to keep the track of users or Client from where did he logged in . I need to get parameter like IP address , location
(latitude,longitude) so how can i get that two parameter in my Web application....


1. IP Address
2. Location

Thanks in Advance,
Arun R.V
Posted
Comments
Abhishek Pant 4-Nov-12 18:21pm    
you can use iplocator plugin in your website

Client IP is pretty easy: HttpContext.Current.Request.UserHostAddress[^] will do it:
Location is harder, and may not be at all accurate, but you can try this API: http://www.hostip.info/use.html[^] - be warned, it may not work. My current IP comes back as "Actually we haven't a clue", but since dynamic IPs are allocated by the ISP it has been in countries a couple of hundred miles away.
 
Share this answer
 
Two Methods for you problem

Common Step:
Get Client IP:
Request.ServerVariables["HTTP_X_FORWARDED_FOR"]
and
Request.ServerVariables["REMOTE_ADDR"]
(one for normal access and other for proxy access.

1. Then you can either get the database of ip list and add it in your database and get the details according to the ip. Link:(forgot the link)

2. Use geo bytes web service to get ip details.
Ex:
C#
var etime_url = 'http://gd.geobytes.com/Gd?after=-1&variables=GeobytesCountry,GeobytesCity,GeobytesRegion';
    AjaxCallFullUrl( etime_url, 'geolocation');
    setTimeout("generateLocation()",2000);


Happy Coding......
 
Share this answer
 
For getting IP Try this... Get IP

Form IP to location it helps you... Geo Location

Others... Geolocation ,

Get city country and country code for a particular ip address in asp
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900