Also related to API (web service)-style method invocations is versioning. By versioning your API, you can have multiple simultaneous versions of it bypossiblytaking different payloads and returning different results. ASP.NET Core supports API versioningthroughtheMicrosoft.AspNetCore.Mvc.Versioninglibrary.
Out of the box, you can apply the following techniques to specify the version that you're interested in:
- A URL query string parameter
- A header
- Any of the previous options—either the query string or a header
Let's say you have two controller classes of the same name in two different namespaces:
namespace Controllers.V1
{
[ApiVersion("1.0")]
public class ApiController
{
[ApiVersion("1.0", Deprecated = true)]
[HttpGet("[controller]/[action]/{version:apiversion}")]
public Model Get() { ... }
[ApiVersion...