.NET

IPGeoTrace for .NET

A typed client for the resolve API, plus optional ASP.NET Core middleware that geolocates the caller once per request. Targets net8.0.

The .NET integration ships as two packages that build on each other:

  • IPGeoTrace.Client - the base client. Inject it and resolve any IP you supply.
  • IPGeoTrace.Client.AspNetCore - adds middleware that resolves the caller automatically and exposes the result on HttpContext.

Install#

The ASP.NET Core package pulls in the base client for you, so most apps only need one line.

bash
dotnet add package IPGeoTrace.Client.AspNetCore

Register the client#

One line in Program.cs wires up the client. Every other setting is optional.

csharp
builder.Services.AddIpGeoTrace(builder.Configuration["IpGeoTrace:ApiKey"]!);

From here you have two independent ways to use the library, and the middleware is optional. Pick whichever fits, or use both.

Two ways to use it#

  • Use the client directly - inject IIpGeoTraceClient and resolve any IP you supply: a signup form, a webhook payload, a stored audit log.
  • Resolve the caller automatically - add the middleware and read the result anywhere via HttpContext.GetGeo() with no IP handling in your code.

Source & package

The client is on NuGet. You need an API key from app.ipgeotrace.com to make live calls.