RzR.Web.Middleware.TraceId 2.0.0.8246

dotnet add package RzR.Web.Middleware.TraceId --version 2.0.0.8246
                    
NuGet\Install-Package RzR.Web.Middleware.TraceId -Version 2.0.0.8246
                    
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="RzR.Web.Middleware.TraceId" Version="2.0.0.8246" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="RzR.Web.Middleware.TraceId" Version="2.0.0.8246" />
                    
Directory.Packages.props
<PackageReference Include="RzR.Web.Middleware.TraceId" />
                    
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 RzR.Web.Middleware.TraceId --version 2.0.0.8246
                    
#r "nuget: RzR.Web.Middleware.TraceId, 2.0.0.8246"
                    
#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 RzR.Web.Middleware.TraceId@2.0.0.8246
                    
#: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=RzR.Web.Middleware.TraceId&version=2.0.0.8246
                    
Install as a Cake Addin
#tool nuget:?package=RzR.Web.Middleware.TraceId&version=2.0.0.8246
                    
Install as a Cake Tool

RzR.Web.Middleware.TraceId is an ASP.NET Core middleware that replaces the default request trace identifier with a custom value you define. On every incoming HTTP request the middleware overwrites HttpContext.TraceIdentifier with the generated identifier and writes that same value to the X-Trace-Id response header, making it straightforward to correlate log entries with specific requests.

The library has no mandatory external dependencies beyond the standard ASP.NET Core abstractions. Once installed it can be wired into the pipeline with a single line of code, and it offers a range of options for teams that need more control over the format or propagation of trace identifiers.

Key features

  • Generates trace identifiers as plain GUIDs, formatted GUIDs, or GUIDs combined with a UTC timestamp.
  • Lets you attach a prefix, suffix, and separator to every generated identifier.
  • Supports W3C Trace Context propagation by reading and writing the traceparent header.
  • Can preserve a trace identifier arriving on an inbound header such as X-Request-Id or X-Correlation-Id, which is useful when chaining requests across microservices.
  • Writes the trace identifier to one or more response headers simultaneously.
  • Optionally opens a structured-logging scope so that every log entry produced during the request automatically carries the trace identifier.
  • Optionally logs the request path and body (up to a configurable size limit) together with the trace identifier.
  • Allows synchronous or asynchronous callbacks to run after the downstream pipeline completes, with access to the fully populated HttpContext.
  • Exposes an ITraceIdAccessor abstraction that can be injected into any service to read the current trace identifier without depending directly on IHttpContextAccessor.
  • Supports configuration through appsettings.json with hot-reload via IOptionsMonitor, so option changes take effect without restarting the application.

Installation

Install the package from NuGet:

Install-Package RzR.Web.Middleware.TraceId

To install a specific version:

Install-Package RzR.Web.Middleware.TraceId -Version x.x.x.x

Quick start

The minimal setup adds the middleware to the request pipeline and generates a new GUID as the trace identifier for every request:

// Program.cs or Startup.cs
app.UseUniqTraceIdMiddleware();

For a more complete setup that binds options from configuration and registers the ITraceIdAccessor service:

// Service registration
builder.Services.AddUniqTraceId(builder.Configuration.GetSection("TraceId"));

// Middleware pipeline
app.UseUniqTraceIdMiddleware();

A minimal appsettings.json section looks like this:

{
  "TraceId": {
    "TraceType": "Guid",
    "ResponseHeaderName": "X-Trace-Id"
  }
}

Full configuration reference and additional usage patterns are covered in the documentation below.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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
2.0.0.8246 106 5/6/2026