I am trying to enable versioning on a REST API, where the version is specified in the header, as "api-version":2
.
According to this tutorial I just need to create
VersionConstraint : IHttpRouteConstraint
and
VersionedRoute: RouteFactoryAttribute
The usage would be to apply the [VersionedRoute("api/controllerName", 2)]
Attribute to Controllers, which are designed for specific versions (e.g. version 2 in this case).
This is all good and well, but unfortunately, it's all in MVC5 and I'm using MVC6. Therefore, RouteFactoryAttribute
and IHttpRouteConstraint
don't work.
I managed to find IRouteConstraint
to replace IHttpRouteConstraint
(hoping it will work), but I cannot find a replacement for RouteFactoryAttribute
.
If anyone can provide a sample of this using MVC 6, or at least mention the correct classes (ideally with namespaces) I need to inherit from?