Views: 1876
Number of votes: 9
Average rating:

Geolocation provider changes

For quite some time Episerver CMS has come with built-in Geolocation support for MaxMind’s GeoLite database. When creating a site using the Episerver CMS Visual Studio Extension or the EPiServer.CMS NuGet package it would come with a recent version of this database included.

But as of late, MaxMind has announced that they are discontinuing the GeoLite database format effective January 2, 2019 and that the database will no longer be updated as of April 1, 2018.

As a replacement, MaxMind is instead offering the free GeoLite2 or the commercial GeoIP2 database which both comes with IPv6 support. These databases do however use a different format than the legacy GeoLite database that’s not compatible with the Geolocation provider included in the current version of Episerver CMS.

For a while, it has been possible to add support for GeoLite2 databases by replacing the built-in Geolocation provider with an excellent third-party provider available from the Episerver NuGet server, written by Khurram Khan, one of our brilliant MVPs.

With the GeoLite support officially coming to an end it no longer makes sense to continue providing the same default Geolocation support. We have therefore decided to make the following changes.

A new provider for GeoLite2 databases

A new separate NuGet package called EPiServer.Personalization.MaxMindGeolocation has been released. This package includes a Geolocation provider with support for MaxMind’s GeoLite2 database and it effectively works as a direct replacement for the provider from the PixieEPiServerExtensionMaxMindGeoIP2 package but with the added support from Episerver. This support is currently limited to usage with MaxMind’s free GeoLite2 City or Country databases, but the commercial GeoIP2 databases should also work although this has not been verified.

This provider needs to be installed separately as the EPiServer CMS package does not have a dependency to it. The Geolocation database can be downloaded from MaxMind’s website directly. To ensure that an updated list of locations is used, the provider also requires the matching CSV file which includes a list of all locations contained in the database. Make sure you specify the path of both the database and the locations file in your configuration such as:

<geolocation defaultProvider="maxmind2">
    <providers>
        <add name="maxmind2" 
             type="EPiServer.Personalization.MaxMindGeolocationProvider, EPiServer.Personalization.MaxMindGeolocation" 
             databaseFileName="path\to\GeoLite2-City.mmdb" 
             locationsFileName="path\to\GeoLite2-City-Locations-en.csv" />
    </providers>
</geolocation>

The paths can be either relative to the website root or absolute.

You can alternatively configure the provider in the ConfigureContainer method of an initialization module that implements IConfigurableModule.

public void ConfigureContainer(ServiceConfigurationContext context)
{
    context.Services.AddMaxMindGeolocationProvider("path\to\geolite2-country.mmdb", "path\to\geolite2-country-locations-en.csv");
}

Note that the names of some regions have changed compared to the old GeoLite database, so if you are using the Geographic Location Visitor Group Criterion down to this level, you may have to update these with the new names.

Use geolocation provided by the CDN

We have also added support for retrieving Geolocation from the current request when provided from the CDN in the form of a header with a country code. Due to its nature, it's limited to Continent and Country location and will only be used for sites that don't have a Geolocation provider configured. This support will be turned on by default for all DXC customers. See Content Delivery Network (CDN) Configuration for additional information on how to enable this option.

Phasing out the old GeoLite provider

The old Geolocation provider currently included in the EPiServer.ApplicationModules assembly inside the EPiServer.Framework package will be obsoleted immediately and removed in a future major release. The EPiServer.CMS package will still contain the legacy GeoLite database for a while longer as removing it would remove it from existing solutions when updating the NuGet package. Once the provider has been fully deprecated, we will remove the database as well.

New sites created using the Episerver CMS Visual Studio Extension will be configured without a Geolocation provider going forward.

If you have any questions in relation to these changes, please comment below or send your question to our support team.

This is great!

But since Find isn't using JSON.NET > 11, and MaxMind.GeoIP2 3.0.0 requires >= 11.0.2, I can't use it. I'm guessing I'm not alone in this.

I've same issue with Find using older version of JSON.net.

Thanks for the comments and sorry about your issues. An update to the Find packages with Json.NET 11 support is in the pipeline, so it should hopefully not be too long for you. I've reached out to the Find team to get a more presice timeline and will post it in another comment if I can.

Thanks for your patience!

Have you tried using the ignore-dependency flag when installing Find (https://docs.microsoft.com/en-us/nuget/tools/ps-ref-install-package)? We will update Find to support Json.Net 11 soon, but our tests shows that Find works with Json.Net 11.

I've run into the same issue. Find 13.0.1 can't use Json.Net 11, so I updated Json.Net while ignoring dependencies. However, when I try to install CsvHelper or Episerver.Personalization.MaxMindGeolocation, I still get a conflict:

Unable to find a version of 'WindowsAzure.Storage' that is compatible with 'EPiServer.Azure 9.4.4 constraint: WindowsAzure.Storage (>= 8.5.0 && < 9.0.0)'

I need Episerver.Azure for DXC, so simply removing it is not an option. Any ideas on where this dependency might be coming from? Ignoring dependencies at this rate is going to create an unstable app.

Please login to comment.