Evenementer
Power BI DataViz World Championships
Feb 14, 4 PM - Mar 31, 4 PM
Mat 4 Chance fir matzemaache kënnt Dir e Konferenz-Pak gewannen an op d’LIVE Grand Finale zu Las Vegas kommen
Méi gewuer ginnDëse Browser gëtt net méi ënnerstëtzt.
Upgrat op Microsoft Edge fir vun de Virdeeler vun leschten Eegeschaften, Sécherheetsupdaten, an techneschem Support ze profitéieren.
The SetCompatibilityVersion method is a no-op for ASP.NET Core 3.0 apps. That is, calling SetCompatibilityVersion
with any value of CompatibilityVersion has no impact on the application.
CompatibilityVersion
value.CompatibilityVersion
values Version_2_0
through Version_2_2
are marked [Obsolete(...)]
.To see how SetCompatibilityVersion
works with ASP.NET Core 2.x apps, select the ASP.NET Core 2.2 version of this article.
The SetCompatibilityVersion method allows an ASP.NET Core 2.x app to opt-in or opt-out of potentially breaking behavior changes introduced in ASP.NET Core MVC 2.1 or 2.2. These potentially breaking behavior changes are generally in how the MVC subsystem behaves and how your code is called by the runtime. By opting in, you get the latest behavior, and the long-term behavior of ASP.NET Core.
The following code sets the compatibility mode to ASP.NET Core 2.2:
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc()
.SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
}
We recommend you test your app using the latest version (CompatibilityVersion.Latest
). We anticipate that most apps won't have breaking behavior changes using the latest version.
Apps that call SetCompatibilityVersion(CompatibilityVersion.Version_2_0)
are protected from potentially breaking behavior changes introduced in the ASP.NET Core 2.1/2.2 MVC versions. This protection:
The default compatibility for ASP.NET Core 2.1 and 2.2 apps that do not call SetCompatibilityVersion
is 2.0 compatibility. That is, not calling SetCompatibilityVersion
is the same as calling SetCompatibilityVersion(CompatibilityVersion.Version_2_0)
.
The following code sets the compatibility mode to ASP.NET Core 2.2, except for the following behaviors:
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc()
// Include the 2.2 behaviors
.SetCompatibilityVersion(CompatibilityVersion.Version_2_2)
// Except for the following.
.AddMvcOptions(options =>
{
// Don't combine authorize filters (keep 2.0 behavior).
options.AllowCombiningAuthorizeFilters = false;
// All exceptions thrown by an IInputFormatter are treated
// as model state errors (keep 2.0 behavior).
options.InputFormatterExceptionPolicy =
InputFormatterExceptionPolicy.AllExceptions;
});
}
For apps that encounter breaking behavior changes, using the appropriate compatibility switches:
The MvcOptions documentation has a good explanation of what changed and why the changes are an improvement for most users.
With ASP.NET Core 3.0, old behaviors supported by compatibility switches have been removed. We feel these are positive changes benefitting nearly all users. By introducing these changes in 2.1 and 2.2, most apps can benefit, while others have time to update.
Feedback zu ASP.NET Core
ASP.NET Core ass en Open-Source-Projet. Wielt e Link, fir Feedback ze ginn:
Evenementer
Power BI DataViz World Championships
Feb 14, 4 PM - Mar 31, 4 PM
Mat 4 Chance fir matzemaache kënnt Dir e Konferenz-Pak gewannen an op d’LIVE Grand Finale zu Las Vegas kommen
Méi gewuer ginn