Skip to content

Accessing Version Information

Chris Martinez edited this page Jul 28, 2016 · 3 revisions

All of the service API version information is accessible via extension methods. These features allow you to determine which API version was requested by a client as well as determine which versions are supported and deprecated. The API versions provided are automatically aggregated across all service implementations.

The most common usage is the current, client requested API version:

ASP.NET Web API

[ApiVersion( "1.0" )]
[ApiVersion( "2.0" )]
public class MyController : ApiController
{
    protected ApiVersion RequestedApiVersion => Request.GetRequestedApiVersion();
}

ASP.NET Core

[ApiVersion( "1.0" )]
[ApiVersion( "2.0" )]
public class Controller : Controller
{
    protected ApiVersion RequestedApiVersion => HttpContext.GetRequestedApiVersion();
}
Clone this wiki locally