Regira.Web.Analytics.GeoIP2 6.2.1

dotnet add package Regira.Web.Analytics.GeoIP2 --version 6.2.1
                    
NuGet\Install-Package Regira.Web.Analytics.GeoIP2 -Version 6.2.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Regira.Web.Analytics.GeoIP2" Version="6.2.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Regira.Web.Analytics.GeoIP2" Version="6.2.1" />
                    
Directory.Packages.props
<PackageReference Include="Regira.Web.Analytics.GeoIP2" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Regira.Web.Analytics.GeoIP2 --version 6.2.1
                    
#r "nuget: Regira.Web.Analytics.GeoIP2, 6.2.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Regira.Web.Analytics.GeoIP2@6.2.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Regira.Web.Analytics.GeoIP2&version=6.2.1
                    
Install as a Cake Addin
#tool nuget:?package=Regira.Web.Analytics.GeoIP2&version=6.2.1
                    
Install as a Cake Tool

Regira.Web.Analytics.GeoIP2

Geolocation for Regira.Web.Analytics: a background enricher that resolves country and city from a local MaxMind GeoIP2/GeoLite2 database, so visitor addresses never leave the server. It runs on the unmasked client IP before the analytics writer truncates it — the seam the core package leaves open on purpose — and it is the only place the MaxMind.GeoIP2 dependency lives.

Setup

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddAnalytics<GeoPageView>(builder.Configuration)   // shipped entity with geo columns
    .WithStore<MyGeoStore>()
    .AddGeoIP2(builder.Configuration);
"Analytics": {
  "GeoIP2": { "DatabasePath": "App_Data" }
}

DatabasePath is an .mmdb file or a directory holding one; a directory prefers a City database over a Country one, so dropping in a City download upgrades from country-level to city-level without a config change. Relative paths resolve against the content root, then the application base directory. No path, or no file found, disables the lookup with a log line — rows simply keep empty geo columns. The database is a licensed MaxMind download (GeoLite2 is free with an account); deploy it next to the app, never commit it.

Your own entity

Implement IGeoPageView on any page-view entity and the enricher fills it:

public class SitePageView : PageView, IGeoPageView
{
    [MaxLength(2)]   public string? CountryCode { get; set; }
    [MaxLength(128)] public string? Country { get; set; }
    [MaxLength(128)] public string? City { get; set; }
    [MaxLength(64)]  public string? Campaign { get; set; }
}
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddAnalytics<SitePageView>(builder.Configuration)
    .WithStore<MyGeoStore>()   // IPageViewStore<in T>: a store of the base entity serves the subclass
    .AddGeoIP2(builder.Configuration);

Swapping the lookup

AddGeoIP2 registers IGeoLocationService with TryAdd, so a service registered before it — another provider, or a fake in tests — is kept and the MaxMind reader is never opened.

Privacy

Lookups skip loopback, link-local and private ranges. The core package's IP masking still applies: the full address is used for the lookup and only the truncated form is stored.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
6.2.1 110 9/5/2026