Query String-Based Versioning in ASP.NET Core
Query String-Based Versioning
In the case of query string based versioning, we have to specify the API version in the query string to call the specific controller. Now we mention the specific version to each controller using [ApiVersion(version_name)] attributes. So our controller looks like the code below:
We can call controller using the below routes with the query string method. To call EmployeeV1Controller, we have to hit as https://localhost:44381/api/employee?api-version=1.0 For EmployeeV2Controller we have to type: https://localhost:44381/api/employee?api-version=2.0 (View Highlight)
Additional Metadata
- Type::snippet
- Origin:: API Versioning in ASP.NET Core
- Status::🌲
- Tags:: CSharp