From the course: Advanced Web APIs with ASP.NET Core in .NET 6

Unlock the full course today

Join today to access over 24,800 courses taught by industry experts.

Implementing query string versioning

Implementing query string versioning - C# Tutorial

From the course: Advanced Web APIs with ASP.NET Core in .NET 6

Implementing query string versioning

- [Christian] The last versioning option we want to discuss is using the QueryString. And that's pretty simple, actually, maybe even simpler than you think. We have our API endpoint, so here is just a potential but unfortunately non-existing URL, and we just append a QueryString to it with a parameter, and I call it api-version, and I set it to the version I want. And why did I call it api-version? There are a couple of reasons. It's specific, but also it works out of the box courtesy of our NuGet package. And with out of the box, I really mean out of the box. All I'm doing in my existing implementation is that I remove setting the ApiVersionReader to the HeaderApiVersionReader. Back in Postman, I remove the X-API-Version HTTP header. So usually the API will now return to its default API version, version 1.0. However, I'm appending api-version=2.0. Send the request to the server. And we see here, we have item…

Contents