Introduction
When you build a Web API in ASP.NET Core, your API will evolve over time. You may add new features, change response formats, or improve existing endpoints. But what happens to existing users who are already using your API?
This is where API versioning becomes very important.
API versioning allows you to maintain multiple versions of your API so that old clients continue to work while new clients can use updated features.
In this article, you will learn how to implement API versioning in ASP.NET Core Web API in a simple, practical, and step-by-step way.
What is API Versioning?
API versioning is a technique that allows different versions of your API to exist at the same time.
In simple words:
Old users continue using version 1
New users can use version 2
Your application remains stable and backward compatible
This is very important in real-world applications where breaking changes can affect thousands of users.
Why API Versioning is Important
API versioning helps you:
Avoid breaking existing clients
Introduce new features safely
Maintain backward compatibility
Manage API lifecycle effectively
Without versioning, even small changes can break applications that depend on your API.
Types of API Versioning in ASP.NET Core
There are multiple ways to implement API versioning:
URL Versioning (most common)
Query String Versioning
Header Versioning
Media Type Versioning
Let’s understand each one in simple terms.
URL Versioning
Version is included in the URL.
Example:
/api/v1/products/api/v2/products
This is the easiest and most widely used approach.
Query String Versioning
Version is passed as a query parameter.
Example:
/api/products?version=1
Header Versioning
Version is passed in request headers.
Example:
api-version: 1
Media Type Versioning
Version is specified in the Accept header.
Example:
application/json;v=1
Prerequisites
Before starting, ensure you have:
ASP.NET Core Web API project
.NET SDK installed
Basic understanding of controllers and routing
Step 1: Install API Versioning Package
Run the following command:
dotnet add package Microsoft.AspNetCore.Mvc.Versioning
This package provides built-in support for API versioning.
Step 2: Configure API Versioning in Program.cs
Open your Program.cs file and add the following configuration:
builder.Services.AddApiVersioning(options =>
{
options.AssumeDefaultVersionWhenUnspecified = true;
options.DefaultApiVersion = new ApiVersion(1, 0);
options.ReportApiVersions = true;
});

Join the conversation! Your thoughts help the community grow.