Strategies 1. URI Each time we change the version, the clients will have to change the URL. 2. Via Query String 3. Via Headers The client needs to have a developer who knows how to deal with headers, more sophisticated approach. Also we need to create our own custom header. 4. VIA ACCEPT HEADERS Add the nuget package -- Microsoft.AspNetCore.Mvc.Versioning [ApiVersion("1.0")] [ApiVersion("1.1")] [ApiVersion("2.0")] public class WeatherForecastController : ControllerBase Add this to the controller to let the user know what version it supports. To the actions Specify these. [HttpGet("sample")] [MapToApiVersion("1.0")] public IActionResult Getv1(string id) => Ok("Version 1"); [HttpGet("sample")] [MapToApiVersion("1.1")] public IActionResult Getv2() => Ok("Version ...
I jot down whatever I learn from different sources.Written for personal use. But anyone can learn.