|
| 1 | +--- |
| 2 | +title: "Breaking change: Microsoft.AspNetCore.Http.Features split up" |
| 3 | +description: "Learn about the breaking change in ASP.NET Core 6.0 where the Microsoft.AspNetCore.Http.Features package has been split, and no longer ships as a package." |
| 4 | +ms.date: 05/06/2021 |
| 5 | +--- |
| 6 | +# Microsoft.AspNetCore.Http.Features split |
| 7 | + |
| 8 | +Microsoft.AspNetCore.Http.Features has been split into the following two assemblies: |
| 9 | + |
| 10 | +- Microsoft.AspNetCore.Http.Features |
| 11 | +- Microsoft.Extensions.Features |
| 12 | + |
| 13 | +For discussion, see GitHub issue [dotnet/aspnetcore#32307](https://github.com/dotnet/aspnetcore/issues/32307). |
| 14 | + |
| 15 | +## Version introduced |
| 16 | + |
| 17 | +ASP.NET Core 6.0 |
| 18 | + |
| 19 | +## Old behavior |
| 20 | + |
| 21 | +Microsoft.AspNetCore.Http.Features 5.0 shipped both in the ASP.NET shared framework and as a NuGet package. Microsoft.AspNetCore.Http.Features 5.0 targeted .NET 4.6.1, .NET Standard 2.0, and .NET 5. |
| 22 | + |
| 23 | +## New behavior |
| 24 | + |
| 25 | +Microsoft.AspNetCore.Http.Features 6.0 ships only in the ASP.NET shared framework, not as a NuGet package. It targets .NET 6 only. |
| 26 | + |
| 27 | +Microsoft.Extensions.Features 6.0 ships in both the ASP.NET shared framework and as a NuGet package. It targets .NET 4.6.1, .NET Standard 2.0, and .NET 6.0. |
| 28 | + |
| 29 | +The following types have been moved to the new Microsoft.Extensions.Features assembly: |
| 30 | + |
| 31 | +- <xref:Microsoft.AspNetCore.Http.Features.IFeatureCollection> |
| 32 | +- <xref:Microsoft.AspNetCore.Http.Features.FeatureCollection> |
| 33 | +- <xref:Microsoft.AspNetCore.Http.Features.FeatureReference%601> |
| 34 | +- <xref:Microsoft.AspNetCore.Http.Features.FeatureReferences%601> |
| 35 | + |
| 36 | +These types are still in the `Microsoft.AspNetCore.Http.Features` namespace, and type forwards have been added for compatibility. |
| 37 | + |
| 38 | +## Reason for change |
| 39 | + |
| 40 | +This change was introduced for two reasons: |
| 41 | + |
| 42 | +- Allows the core types to be shared more broadly across components. |
| 43 | +- Allows the remaining Http-specific components in Microsoft.AspNetCore.Http.Features to take advantage of new runtime and language features. |
| 44 | + |
| 45 | +## Recommended action |
| 46 | + |
| 47 | +When upgrading to ASP.NET 6.0, remove any packages references for Microsoft.AspNetCore.Http.Features. Add a package reference for Microsoft.Extensions.Features only if required. |
| 48 | + |
| 49 | +For class libraries that need to consume the types from Microsoft.AspNetCore.Http.Features, add a `FrameworkReference` instead: |
| 50 | + |
| 51 | +```xml |
| 52 | +<ItemGroup> |
| 53 | + <FrameworkReference Include="Microsoft.AspNetCore.App" /> |
| 54 | +</ItemGroup> |
| 55 | +``` |
| 56 | + |
| 57 | +For more information about adding the framework reference, see [Use the ASP.NET Core shared framework](/aspnet/core/fundamentals/target-aspnetcore?#use-the-aspnet-core-shared-framework). |
| 58 | + |
| 59 | +Libraries with out of date references may encounter a <xref:System.TypeLoadException> or the following error: |
| 60 | + |
| 61 | +**Error CS0433 The type 'IFeatureCollection' exists in both 'Microsoft.AspNetCore.Http.Features, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' and 'Microsoft.Extensions.Features, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'** |
| 62 | + |
| 63 | +To resolve the error, add a `FrameworkReference` to Microsoft.AspNetCore.App to any of the affected projects. |
| 64 | + |
| 65 | +For questions, see [dotnet/aspnetcore#32307](https://github.com/dotnet/aspnetcore/issues/32307). |
| 66 | + |
| 67 | +## Affected APIs |
| 68 | + |
| 69 | +- <xref:Microsoft.AspNetCore.Http.Features.IFeatureCollection?displayProperty=fullName> |
| 70 | +- <xref:Microsoft.AspNetCore.Http.Features.FeatureCollection?displayProperty=fullName> |
| 71 | +- <xref:Microsoft.AspNetCore.Http.Features.FeatureReference%601?displayProperty=fullName> |
| 72 | +- <xref:Microsoft.AspNetCore.Http.Features.FeatureReferences%601?displayProperty=fullName> |
| 73 | + |
| 74 | +<!-- |
| 75 | +
|
| 76 | +## Category |
| 77 | +
|
| 78 | +ASP.NET Core |
| 79 | +
|
| 80 | +## Affected APIs |
| 81 | +
|
| 82 | +- `T:Microsoft.AspNetCore.Http.Features.IFeatureCollection` |
| 83 | +- `T:Microsoft.AspNetCore.Http.Features.FeatureCollection` |
| 84 | +- `T:Microsoft.AspNetCore.Http.Features.FeatureReference%601` |
| 85 | +- `T:Microsoft.AspNetCore.Http.Features.FeatureReferences%601` |
| 86 | +
|
| 87 | +--> |
0 commit comments