QueryGuard.AspNetCore 0.1.0-preview.6

Prefix Reserved
This is a prerelease version of QueryGuard.AspNetCore.
There is a newer version of this package available.
See the version list below for details.
dotnet add package QueryGuard.AspNetCore --version 0.1.0-preview.6
                    
NuGet\Install-Package QueryGuard.AspNetCore -Version 0.1.0-preview.6
                    
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="QueryGuard.AspNetCore" Version="0.1.0-preview.6" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="QueryGuard.AspNetCore" Version="0.1.0-preview.6" />
                    
Directory.Packages.props
<PackageReference Include="QueryGuard.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 QueryGuard.AspNetCore --version 0.1.0-preview.6
                    
#r "nuget: QueryGuard.AspNetCore, 0.1.0-preview.6"
                    
#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 QueryGuard.AspNetCore@0.1.0-preview.6
                    
#: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=QueryGuard.AspNetCore&version=0.1.0-preview.6&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=QueryGuard.AspNetCore&version=0.1.0-preview.6&prerelease
                    
Install as a Cake Tool

QueryGuard.AspNetCore

Opens a QueryGuard.NET session around each ASP.NET Core request, so repeated EF Core queries can be grouped per endpoint and query budgets evaluated per route.

Quickstart

builder.Services.AddQueryGuard(options =>
{
    // Recommended for the first preview: development and test environments.
    options.Enabled = builder.Environment.IsDevelopment();

    options.DefaultPolicy = QueryGuardPolicy.Create("default")
        .WithMaxQueries(20, QueryGuardSeverity.Warning)
        .WithMaxOccurrencesPerFingerprint(5, QueryGuardSeverity.Failure);
});

builder.Services.AddDbContext<AppDbContext>((services, db) =>
{
    db.UseSqlite(connectionString);
    db.AddInterceptors(services.GetRequiredService<QueryGuardCommandInterceptor>());
});

var app = builder.Build();

app.UseRouting();

// After UseRouting, so a scope is named by its matched route pattern rather than its URL. Earlier and
// every request lands in one "(unmatched)" scope: QueryGuard still works, the reports just lose the
// one label that makes them useful.
app.UseQueryGuard();

The middleware observes and nothing else

It does not write to the response body, add headers, or throw on the request path. The response your application produces and the exception it raises are exactly what a client sees, with QueryGuard enabled or disabled. Findings go to ILogger with stable event IDs.

That is a deliberate constraint, not a missing feature: see ADR-0006.

Policies are per route pattern

A policy is selected by the endpoint's route pattern, so /api/companies/1 and /api/companies/2 share the policy for GET /api/companies/{id} rather than creating one per identifier.

options.ForEndpoint("GET /api/reports/{id}", policy => policy
    .WithMaxQueries(40)
    .AllowFingerprint("QG-FP-1A2B3C4D", reason: "Bounded provider lookup; at most three sections."));

Preview

Public APIs may change before 1.0.0. See the changelog.

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 (1)

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

Package Downloads
QueryGuard.AspNetCore.Testing

Measure EF Core queries from WebApplicationFactory tests with one setup call. Preserves the test execution context, disables request middleware, and wires the matching session accessor.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.0 45 8/21/2026
0.1.0-preview.6 50 8/21/2026
0.1.0-preview.5 51 8/21/2026
0.1.0-preview.4 44 8/20/2026
0.1.0-preview.3 42 8/20/2026
0.1.0-preview.2 39 8/20/2026
0.1.0-preview.1 44 8/20/2026