Meziantou.AspNetCore 2.0.2

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

Meziantou.AspNetCore

Helpers for ASP.NET Core middleware diagnostics and response cache-control behavior.

Features

  • Capture and inspect the middleware pipeline
  • Expose a debug endpoint returning the pipeline and endpoints as JSON
  • Access middleware pipeline snapshots from code
  • Add a default non-cacheable Cache-Control response header when none is set

Usage

Middleware pipeline debugging

The diagnostics extension methods are in the Meziantou.AspNetCore.Diagnostics namespace.

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddMiddlewarePipelineDebugging(); // must run before builder.Build()

var app = builder.Build();

app.UseRouting();
app.MapGet("/hello", static () => "hello");

// Maps GET /_debug/pipeline. By default it responds only in Development and returns 404 elsewhere.
app.MapMiddlewarePipelineDebugEndpoint();

app.MapGet("/pipeline.txt", () =>
{
    var snapshot = app.GetMiddlewarePipelineDebugSnapshot();
    return Results.Text(snapshot.ToString(), "text/plain");
});

app.Run();

The default route is /_debug/pipeline; pass a different pattern to change it.

What is captured

Capture works through an IStartupFilter, which observes the host pipeline. This matters:

  • Middleware registered from an IStartupFilter or a classic Configure method is captured individually, including Map / MapWhen / UseWhen branches.
  • Middleware registered directly on WebApplication is not captured individually. WebApplication hands the host a single component representing its entire pipeline, so it appears as one entry named after that component (...WebApplicationBuilder+WireSourcePipeline.CreateMiddleware). Its branches are not visible either.

Names are resolved on a best-effort basis from the registration delegate. When a name cannot be resolved it degrades to the delegate's declaring type and method — it is never inferred from unrelated state, so a name you see belongs to the middleware it is listed against.

Snapshot timing

The pipeline is captured while the host builds it. A snapshot taken earlier reports IsPipelineCaptured == false and an empty pipeline — including inside an IHostedService, which starts before the web host. Read the snapshot after the host has started.

Securing the debug endpoint

The endpoint is not authenticated. It discloses every registered route, the middleware order and implementation type names. The default (developmentOnly: true) responds only in Development. To expose it elsewhere, gate it:

app.MapMiddlewarePipelineDebugEndpoint(developmentOnly: false)
   .RequireAuthorization("DiagnosticsPolicy");

Note that MiddlewarePipelineDebugEndpoint.Endpoint is excluded from serialization, so it is null on a snapshot deserialized from the endpoint's JSON. It is only populated on a snapshot created in-process.

Default no-cache response header

UseNoCache is in the Meziantou.AspNetCore namespace.

var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();

app.UseNoCache();

app.MapGet("/", static () => "Hello World!");

app.Run();

UseNoCache sets Cache-Control: no-cache,no-store,must-revalidate only when the response does not already define Cache-Control (an empty value counts as not defined). Responses that set their own Cache-Control are never modified, and if the response has already started the header is left alone rather than failing the request.

Two consequences worth knowing before adding it:

  • Register it after anything serving cacheable content, such as UseStaticFiles. The static file middleware sets ETag and Last-Modified but no Cache-Control, so an earlier registration marks every static asset non-cacheable.
  • Because the default includes no-store, responses it defaults are not stored by UseResponseCaching, UseOutputCache or a CDN.
Product Compatible and additional computed target framework versions.
.NET 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.  net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.
  • net11.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Meziantou.AspNetCore:

Package Downloads
Meziantou.AspNetCore.ServiceDefaults

Opinionated ASP.NET Core defaults for OpenTelemetry, health checks, resilience, service discovery, and security

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.2 235 10/21/2026
2.0.1 2,783 9/6/2026
2.0.0 6,078 7/5/2026
1.0.3 1,531 6/13/2026
1.0.2 902 5/23/2026
1.0.1 780 5/11/2026
1.0.0 778 4/25/2026