NetEvolve.Http.Correlation.HttpClient
3.3.181
Prefix Reserved
dotnet add package NetEvolve.Http.Correlation.HttpClient --version 3.3.181
NuGet\Install-Package NetEvolve.Http.Correlation.HttpClient -Version 3.3.181
<PackageReference Include="NetEvolve.Http.Correlation.HttpClient" Version="3.3.181" />
<PackageVersion Include="NetEvolve.Http.Correlation.HttpClient" Version="3.3.181" />
<PackageReference Include="NetEvolve.Http.Correlation.HttpClient" />
paket add NetEvolve.Http.Correlation.HttpClient --version 3.3.181
#r "nuget: NetEvolve.Http.Correlation.HttpClient, 3.3.181"
#:package NetEvolve.Http.Correlation.HttpClient@3.3.181
#addin nuget:?package=NetEvolve.Http.Correlation.HttpClient&version=3.3.181
#tool nuget:?package=NetEvolve.Http.Correlation.HttpClient&version=3.3.181
NetEvolve.Http.Correlation.HttpClient
HTTP client delegating handler for forwarding correlation IDs in outgoing requests.
Overview
This package provides a DelegatingHandler implementation that automatically adds correlation IDs to outgoing HTTP requests. It ensures that correlation IDs flow through your distributed system by reading them from the current context and adding them to request headers.
Key Features
- Automatic Header Forwarding: Adds correlation ID to outgoing HTTP requests
- Context-Aware: Reads the correlation ID and header of the request currently in flight, per call
- Flexible Header Support: Supports
X-Correlation-ID(primary) andX-Request-ID(alternative) - Seamless Integration: Works with
IHttpClientFactoryandHttpClientBuilder - Multi-Framework Support: Compatible with .NET 8.0, 9.0, and 10.0
Installation
dotnet add package NetEvolve.Http.Correlation.HttpClient
Usage
Basic Setup
Configure HTTP client with correlation forwarding in your Program.cs:
using NetEvolve.Http.Correlation;
var builder = WebApplication.CreateBuilder(args);
// Register correlation services (from AspNetCore package)
builder.Services.AddHttpCorrelation();
// Configure HTTP client with correlation forwarding
builder.Services
.AddHttpClient("MyApiClient")
.WithHttpCorrelation();
var app = builder.Build();
app.UseHttpCorrelation();
app.Run();
Named Clients
Add correlation handling to specific HTTP clients:
builder.Services
.AddHttpClient<IMyService, MyService>(client =>
{
client.BaseAddress = new Uri("https://api.example.com");
})
.WithHttpCorrelation();
Typed Clients
Works seamlessly with typed HTTP clients:
public class MyApiClient
{
private readonly HttpClient _httpClient;
public MyApiClient(HttpClient httpClient)
{
_httpClient = httpClient;
}
public async Task<string> GetDataAsync()
{
// Correlation ID is automatically added to this request
return await _httpClient.GetStringAsync("/data");
}
}
// Registration
builder.Services
.AddHttpClient<MyApiClient>()
.WithHttpCorrelation();
How It Works
The HttpCorrelationIdHandler is a DelegatingHandler that:
- Reads the correlation of the request currently in flight, as published by
UseHttpCorrelation()(ASP.NET Core or Azure Functions) - Adds the correlation ID to the outgoing request headers, unless the request already carries it
- Uses the same header the incoming request arrived with (
X-Correlation-IDorX-Request-ID)
The correlation is read on every call rather than captured when the handler is created. IHttpClientFactory builds and caches handlers in its own dependency injection scope and shares them across requests, so each outgoing call carries the identifier of the request that made it. Outside of a request, for example in a hosted service or a timer triggered function, no correlation header is added.
Related Packages
Required Package
- NetEvolve.Http.Correlation.Abstractions - Core abstractions and interfaces
Companion Packages
- NetEvolve.Http.Correlation.AspNetCore - ASP.NET Core middleware (publishes the correlation of incoming requests)
- NetEvolve.Http.Correlation.Azure.Functions - Azure Functions middleware (publishes the correlation of HTTP triggered invocations)
- NetEvolve.Http.Correlation.Ulid - ULID-based correlation ID provider
- NetEvolve.Http.Correlation.TestGenerator - Test-friendly provider
Dependencies
NetEvolve.Http.Correlation.AbstractionsMicrosoft.AspNetCore.App(Framework Reference)
License
Licensed under the MIT License. See LICENSE for details.
| Product | Versions 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 is compatible. 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. |
-
net10.0
- NetEvolve.Http.Correlation.Abstractions (>= 3.3.181)
-
net8.0
- NetEvolve.Http.Correlation.Abstractions (>= 3.3.181)
-
net9.0
- NetEvolve.Http.Correlation.Abstractions (>= 3.3.181)
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 |
|---|---|---|
| 3.3.181 | 49 | 10/25/2026 |
| 3.3.61 | 206 | 8/23/2026 |
| 3.3.32 | 127 | 8/13/2026 |
| 3.3.7 | 513 | 7/30/2026 |
| 3.3.4 | 138 | 7/29/2026 |
| 3.1.179 | 132 | 7/26/2026 |
| 3.1.64 | 481 | 4/20/2026 |
| 3.1.23 | 154 | 3/31/2026 |
| 3.1.0 | 152 | 3/23/2026 |
| 3.0.251 | 163 | 3/16/2026 |
| 3.0.138 | 172 | 1/14/2026 |
| 3.0.0 | 281 | 11/23/2025 |
| 2.3.56 | 285 | 10/20/2025 |
| 2.3.3 | 512 | 5/4/2025 |
| 2.3.1 | 308 | 4/9/2025 |
| 2.2.85 | 268 | 9/12/2024 |
| 2.2.75 | 250 | 8/26/2024 |
| 2.2.44 | 258 | 6/11/2024 |
| 2.2.15 | 278 | 5/21/2024 |
| 2.2.11 | 280 | 5/21/2024 |