ApiVersioning.AspNetCore 1.0.1

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

ApiVersioning.AspNetCore

ASP.NET Core middleware that redirects unversioned /api/ requests to /api/v1/ (or a configured default version) using a 308 Permanent Redirect — preserving the HTTP method and request body (unlike 301/302, which may downgrade POST to GET).

Every service in the platform exposes versioned endpoints under /api/v1/... but wants unversioned /api/... callers to be forwarded transparently. This package standardizes that contract with one line of setup, replacing the ~29-line ApiVersionRedirectMiddleware.cs copy that was hand-rolled in each service.

Installation

dotnet add package ApiVersioning.AspNetCore

Quick Start

using ApiVersioning.AspNetCore.Extensions;

// Register BEFORE endpoint routing / FastEndpoints so it matches ahead of the versioned handlers.
app.UseApiVersionRedirect();

Exempting stable, unversioned paths (e.g. webhooks)

External webhook callbacks (Stripe, etc.) sit on a stable unversioned URL and do not follow redirects — a 308 would silently swallow the event. Exempt them:

app.UseApiVersionRedirect(o => o.ExemptPathPrefixes = ["/api/webhooks/"]);

Options

Option Default Purpose
DefaultVersion v1 Version segment inserted after /api.
StatusCode 308 Redirect status. 308 preserves method + body.
ExemptPathPrefixes [] /api/ sub-prefixes that must NOT be redirected.

Behaviour

  • /api/surveys → 308 → Location: /api/v1/surveys (query string preserved).
  • /api/v1/surveys → passes through (already versioned).
  • /health, /swagger, non-/api/ paths → pass through.
  • Matching is case-insensitive.

License

MIT

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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.

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
1.0.1 404 7/1/2026