URL based versioning in ASP.NET Core
URL based Versioning
In this type of versioning, we can define versions in a URL so that it is more readable. Most users prefer this type over other types. You can to URL based versioning by changing the routs as [Route("api/{v:apiVersion}/Values")]
.
Let’s modify the Route attribute in our both controller, as follows.
To call EmployeeV1Controller, we have to hit as
https://localhost:44381/api/1.0/employee
To call EmployeeV2Controller we need: https://localhost:44381/api/2.0/employee
(View Highlight)
Additional Metadata
- Type::snippet
- Origin:: API Versioning in ASP.NET Core
- Status::🌲
- Tags:: CSharp