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 header versioning

Implementing header versioning

- [Teacher] I usually prefer using an HTTP header for a version number. And if you would like to do that, thanks to our Newgate package, there's very little we need to do to make this work and happen. Once again, we start with our controller, with our API controller to be precise, and we use the API version attribute to say which version it is or it represents. And then we set the route and this time there is no version number in the route because we would like to use an HTTP header. So just something like products would be a route or whatever you would like to choose but we need to remove the version number because if we had the version number, the route, there would be no need for the extra HTTP header. The only thing missing now, is that we need to tell the web API how that header is called, because as I've already mentioned, the name is arbitrary and here's how that's done. In the options for our API versioning,…

Contents