The out of the box Geo location API for Episerver uses an old version of the Geo IP database. For some customers, because this is not an updated database, IP addresses show up in the wrong location when personalizing content. There are a few versions of the database that are more accurate but require payment. There is a free option mentioned in a blog post that you can use that is currently maintained. If you run into issues, we would suggest you try this method. Though not supported by our support team, we were able to get it to work internally following the steps below.
For CMS 11.6 and newer customers, please see the newest Episerver Maxmind package instead of the below.
- Download the code for the Maxmind Geo IP extension from https://github.com/khurramkhang/Maxmind.GeoIP
- Open the solution and change the Nuget feed for the Episerver Framework to match your version.
- Note: there may be dependency issues with your version of Epi and the Newtonsoft.Json requirement so you may need to use a slightly older version of the maxmind database
- Build the solution.
- Add a reference in your Epi project to the Pixie.Extensions.Maxmind.GeoIp.dll generated by the build
- Download the GeoLite2 City database to unpack and add the GeoLite2-City.mmdb file to your app_data in your project.
- Please note the license attribution section on the GeoLite2 database download page that you must add.
- Replace the geolocation tags in your web.config with the following (update the location if needed)
<add name="maxmind" type="Pixie.Extensions.Maxmind.GeoIp.Provider.MaxmindGeoIp2, Pixie.Extensions.Maxmind.GeoIp" databaseFileName="App_Data\GeoLite2-City.mmdb" />
- Rebuild your Episerver project
Note: If you build it this way, you will have to update this dll reference when you update your Epi Project to keep them on the same version.
If you'd like to test specific ip addresses against the database you can use this code snippet.
Pixie.Extensions.Maxmind.GeoIp.Services.GeolocationMaxmindService service = new Pixie.Extensions.Maxmind.GeoIp.Services.GeolocationMaxmindService(); var ip = System.Net.IPAddress.Parse("188.8.131.52"); var nvc = new System.Collections.Specialized.NameValueCollection(); nvc.Add("databaseFileName", "full path to location of GeoLite2-City.mmdb (Ex C:\\site\\app_data\\GeoLite2-City.mmdb"); var results = service.GetGeoLocation(ip, nvc);