How can I approximate user location through their IP address on server side?
For a local solution, you can use a database file. You can find free ones with virtually limited accuracy below:
- Maxmind: https://dev.maxmind.com/geoip/geoip2/geolite2/
- Ip2location: https://lite.ip2location.com/database/ip-country-region-city-latitude-longitude-zipcode-timezone
There exists paying variants with better accuracy. However, when using a local database file, you should ask yourself some questions:
- Do you want to implement the local database file loading/lookup by yourself?
- Do you know how to update your database file with no service interruption (IP allocations change frequently)?
- Is your solution scaling to your needs (in terms of requests/second and latency)?
- Don't you need to deduce transient information (timezone, currency, etc.)?
If the answer is No to one of the previous questions, you should most probably use an IP Geolocation API. I suggest having a look at my service, Ipregistry: it is fast, reliable and inexpensive.
Finding Location through IP address Nodejs mongodb
You can utilize GeoIP-lite to get the geodata from the ip address.
var geoip = require('geoip-lite');
var ip = "207.97.227.239";
var geo = geoip.lookup(ip);
console.log(geo);
/*{ range: [ 3479297920, 3479301339 ],
country: 'US',
region: 'TX',
city: 'San Antonio',
ll: [ 29.4889, -98.3987 ],
metro: 641,
zip: 78218 }*/
How to get the geographic location using IP Address in asp.net mvc
This should help you - http://freegeoip.net/
freegeoip.net is a public REST API for searching geolocation of IP addresses and host names.
Send HTTP GET requests to: freegeoip.net/{format}/{ip_or_hostname}. The API supports both HTTP and HTTPS and Supported formats are csv, xml or json.
IP to Location using Javascript
You can submit the IP you receive to an online geolocation service, such as http://www.geoplugin.net/json.gp?ip=<your ip here>&jsoncallback=<suitable javascript function in your source>
, then including the source it returns which will run the function you specify in jsoncallback
with the geolocation information.
Alternatively, you may want to look into HTML5's geolocation features -- you can see a demo of it in action here. The advantage of this is that you do not need to make requests to foreign servers, but it may not work on browsers that do not support HTML5.
Related Topics
Hangfire - Multi Tenant, ASP.NET Core - Resolving the Correct Tenant
Casting VS Converting an Object Tostring, When Object Really Is a String
Why Do Some C# Lambda Expressions Compile to Static Methods
Winforms Issue - Error Creating Window Handle
Rotate a Point by Another Point in 2D
How to Create Custom Propertygrid Editor Item Which Opens a Form
When to Use Enums, and When to Replace Them with a Class with Static Members
How to Use a C# Class Library in a Project
Recommendations on Parsing .Eml Files in C#
Start May Not Be Called on a Promise-Style Task. Exception Is Coming
With Unity How to Inject a Named Dependency into a Constructor
How Is Memory Allocated for a Static Variable
A Textbox/Richtextbox That Has Syntax Highlighting? [C#]
Any Way to Turn the "Internet Off" in Windows Using C#
How to Check If Int Is Legal Enum in C#
ASP.NET MVC 3: Override "Name" Attribute with Textboxfor