MvcBuilderExtensions Class
Defines extension methods for adding version-related capabilities and endpoints to an MVC framework based HTTP API.
public static class MvcBuilderExtensionsInheritance System.Object 🡒 MvcBuilderExtensions
Methods
Section titled “Methods”MvcBuilderExtensions.AddVersionedServiceInformationEndpoints(this IMvcBuilder, string) Method
Section titled “MvcBuilderExtensions.AddVersionedServiceInformationEndpoints(this IMvcBuilder, string) Method”Adds the VersionInformationController endpoints to the MVC application, providing a root endpoint that returns service version information.
public static Microsoft.Extensions.DependencyInjection.IMvcBuilder AddVersionedServiceInformationEndpoints(this Microsoft.Extensions.DependencyInjection.IMvcBuilder mvcBuilder, string? basePath=null);Parameters
Section titled “Parameters”mvcBuilder Microsoft.Extensions.DependencyInjection.IMvcBuilder
The Microsoft.Extensions.DependencyInjection.IMvcBuilder to register the version information endpoints with.
basePath System.String
An optional base path prefix for the version information endpoints. When null, the endpoints are registered at the application root.
Returns
Section titled “Returns”Microsoft.Extensions.DependencyInjection.IMvcBuilder
The mvcBuilder for chaining.
MvcBuilderExtensions.SelectEndpointsByNamespaceAndMediaTypeVersion(this IMvcBuilder, HttpStatusCode) Method
Section titled “MvcBuilderExtensions.SelectEndpointsByNamespaceAndMediaTypeVersion(this IMvcBuilder, HttpStatusCode) Method”Adds media type based API versioning to an MVC framework based HTTP API.
Also registers an Microsoft.Extensions.Options.IPostConfigureOptions<> singleton that installs a DocInclusionPredicate
so ApiVersionConstraintAttribute-annotated actions appear in the correct per-version OpenAPI document.
public static Microsoft.Extensions.DependencyInjection.IMvcBuilder SelectEndpointsByNamespaceAndMediaTypeVersion(this Microsoft.Extensions.DependencyInjection.IMvcBuilder mvcBuilder, System.Net.HttpStatusCode statusCodeOnUnmatchedVersion=System.Net.HttpStatusCode.NotFound);Parameters
Section titled “Parameters”mvcBuilder Microsoft.Extensions.DependencyInjection.IMvcBuilder
The Microsoft.Extensions.DependencyInjection.IMvcBuilder used to setup the application.
statusCodeOnUnmatchedVersion System.Net.HttpStatusCode
The HTTP status code that should be returned by the application if no matching endpoint can be found for a requested API version.
Returns
Section titled “Returns”Microsoft.Extensions.DependencyInjection.IMvcBuilder
The mvcBuilder for chaining.