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

Unlock the full course today

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

Implementing URL versioning

Implementing URL versioning

- [Instructor] Let's commence with, well, at least according to my preferences, the second best option, using the URL for version information. And with that I mean part of the path, not the query string. With the NuGet package we just installed, most of the actual work is already done. We just need to do some extra configuration. We start with our products controller, which is an API controller, and what we now do is we add another attribute, and that attribute is called API Version. That attribute receives the version number we intend to use as a parameter. So basically we are saying this products controller is, in our case, version 1.0 of our API. And we could implement another controller, and that other controller then would be another API version. And then we are setting up a route. The syntax looks a little bit special here, but essentially it says slash V, and then the API version number. So in our case, v1.0/products is the route for that controller. That's all we need to do…

Contents