CompatibilityVersion Enum

Definition

Caution

This API is obsolete and will be removed in a future version. Consider removing usages.

Specifies the version compatibility of runtime behaviors configured by MvcOptions.

public enum class CompatibilityVersion
public enum CompatibilityVersion
[System.Obsolete("This API is obsolete and will be removed in a future version. Consider removing usages.", DiagnosticId="ASP5001", UrlFormat="https://aka.ms/aspnetcore-warnings/{0}")]
public enum CompatibilityVersion
type CompatibilityVersion = 
[<System.Obsolete("This API is obsolete and will be removed in a future version. Consider removing usages.", DiagnosticId="ASP5001", UrlFormat="https://aka.ms/aspnetcore-warnings/{0}")>]
type CompatibilityVersion = 
Public Enum CompatibilityVersion
Inheritance
CompatibilityVersion
Attributes

Fields

Name Value Description
Version_2_0 0

Sets the default value of settings on MvcOptions to match the behavior of ASP.NET Core MVC 2.0.

Version_2_1 1

Sets the default value of settings on MvcOptions to match the behavior of ASP.NET Core MVC 2.1.

Version_2_2 2

Sets the default value of settings on MvcOptions to match the behavior of ASP.NET Core MVC 2.2.

Version_3_0 3

Sets the default value of settings on MvcOptions and other Options types to match the behavior of ASP.NET Core MVC 3.0.

Latest 2147483647

Sets the default value of settings on MvcOptions to match the latest release. Use this value with care, upgrading minor versions will cause breaking changes when using Latest.

Remarks

The best way to set a compatibility version is by using SetCompatibilityVersion(IMvcBuilder, CompatibilityVersion) or SetCompatibilityVersion(IMvcCoreBuilder, CompatibilityVersion) in your application's ConfigureServices method.

public class Startup
{
    ...

    public void ConfigureServices(IServiceCollection services)
    {
        services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_3_0);
    }

    ...
}

Setting compatibility version to a specific version will change the default values of various settings to match a particular minor release of ASP.NET Core MVC.

Applies to