Trellis.Asp.ApiVersioning
3.0.0-alpha.304
See the version list below for details.
dotnet add package Trellis.Asp.ApiVersioning --version 3.0.0-alpha.304
NuGet\Install-Package Trellis.Asp.ApiVersioning -Version 3.0.0-alpha.304
<PackageReference Include="Trellis.Asp.ApiVersioning" Version="3.0.0-alpha.304" />
<PackageVersion Include="Trellis.Asp.ApiVersioning" Version="3.0.0-alpha.304" />
<PackageReference Include="Trellis.Asp.ApiVersioning" />
paket add Trellis.Asp.ApiVersioning --version 3.0.0-alpha.304
#r "nuget: Trellis.Asp.ApiVersioning, 3.0.0-alpha.304"
#:package Trellis.Asp.ApiVersioning@3.0.0-alpha.304
#addin nuget:?package=Trellis.Asp.ApiVersioning&version=3.0.0-alpha.304&prerelease
#tool nuget:?package=Trellis.Asp.ApiVersioning&version=3.0.0-alpha.304&prerelease
Trellis.Asp.ApiVersioning
API-versioning helpers for Trellis.Asp — auto-injects the api-version route value into Location headers so responses round-trip the requested version under query/header API versioning.
Installation
dotnet add package Trellis.Asp.ApiVersioning
Quick Example
using Trellis;
using Trellis.Asp;
using Trellis.Asp.ApiVersioning;
result.ToHttpResponse(opts => opts
.CreatedAtRoute("Customers_GetById", c => c.Id.Value)
.WithVersionedRoute());
// ↑ Location header includes ?api-version=<requested-version> automatically.
WithVersionedRoute() chains after any builder method that emits a builder-generated Location header — including CreatedAtRoute(...) / CreatedAtAction(...) (201 Created) and WithLocation(...) (2xx state-transition responses on existing resources).
Why
Under query/header API versioning, Location headers from CreatedAtRoute(...) / CreatedAtAction(...) / WithLocation(...) silently omit the api-version parameter unless every author remembers to add it to the route values dictionary — a recurring source of dereference 404s that's invisible without integration tests. WithVersionedRoute() injects the version at request time using the configured IApiVersionReader chain, with sensible fallbacks and explicit failures for ambiguous configurations.
Key Features
- Composes with
CreatedAtRoute(...),CreatedAtAction(...),WithLocation(...), and any other builder-generated Location method - Two overloads: per-request resolution (default) and explicit-version pinning (
WithVersionedRoute(ApiVersion)) - Per-request resolution via
httpContext.RequestedApiVersion(theAsp.Versioning.Httpextension property), falling back to declared and default versions - Honours
[ApiVersionNeutral]and URL-segment versioning by skipping injection (applies to both overloads — even explicit pinning won't inject a version into a neutral-endpoint Location or duplicate a path-segment version) - Throws on degenerate configurations (multi-version action with no client-requested version and no
DefaultApiVersion) instead of silently picking
Documentation
Part of Trellis
This package is part of the Trellis framework.
| Product | Versions 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. |
-
net10.0
- Asp.Versioning.Http (>= 10.0.0)
- Asp.Versioning.Mvc (>= 10.0.0)
- Asp.Versioning.Mvc.ApiExplorer (>= 10.0.0)
- Trellis.Asp (>= 3.0.0-alpha.304)
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.0.0-alpha.342 | 0 | 6/5/2026 |
| 3.0.0-alpha.337 | 40 | 6/3/2026 |
| 3.0.0-alpha.336 | 38 | 6/3/2026 |
| 3.0.0-alpha.304 | 58 | 5/29/2026 |