Vaccano
Vaccano

Reputation: 82291

Assembly Microsoft.AspNetCore.Http version 3.0.0.0 Conflict with 2.2.0.0

I need to create an IAuthorizationFilter in my application, which is targeting .NET Core 3.0.

I needed a reference to Microsoft.AspNetCore.Http.DefaultHttpContext. That lives in the Microsoft.AspNetCore.Http namespace.

When I added the NuGet for Microsoft.AspNetCore.Http, I got an error saying that assembly 'Microsoft.AspNetCore.Mvc.Abstractions' with version 3.0.0.0 conflicted with 'Microsoft.AspNetCore.Http.Abstractions' with version 2.2.0.0.

When I looked, the NuGet I installed was version 2.2.0. But the problem is that there is not one for version 3.0 on NuGet.

How can I get a reference to Microsoft.AspNetCore.Http.DefaultHttpContext using .NET Core 3.0?

Upvotes: 2

Views: 11458

Answers (3)

Julian
Julian

Reputation: 36700

In your .csproj file, replace

<PackageReference Include="Microsoft.AspNetCore.Http" Version="..." />

with

<FrameworkReference Include="Microsoft.AspNetCore.App" />

See docs

and

A large number of NuGet packages aren't produced for ASP.NET Core 3.0. Such package references should be removed from your project file.

from migration guide

This is needed for all these packages:

  • Microsoft.AspNetCore
  • Microsoft.AspNetCore.All
  • Microsoft.AspNetCore.App
  • Microsoft.AspNetCore.Antiforgery
  • Microsoft.AspNetCore.Authentication
  • Microsoft.AspNetCore.Authentication.Abstractions
  • Microsoft.AspNetCore.Authentication.Cookies
  • Microsoft.AspNetCore.Authentication.Core
  • Microsoft.AspNetCore.Authentication.OAuth
  • Microsoft.AspNetCore.Authorization.Policy
  • Microsoft.AspNetCore.CookiePolicy
  • Microsoft.AspNetCore.Cors
  • Microsoft.AspNetCore.Diagnostics
  • Microsoft.AspNetCore.Diagnostics.HealthChecks
  • Microsoft.AspNetCore.HostFiltering
  • Microsoft.AspNetCore.Hosting
  • Microsoft.AspNetCore.Hosting.Abstractions
  • Microsoft.AspNetCore.Hosting.Server.Abstractions
  • Microsoft.AspNetCore.Http
  • Microsoft.AspNetCore.Http.Abstractions
  • Microsoft.AspNetCore.Http.Connections
  • Microsoft.AspNetCore.Http.Extensions
  • Microsoft.AspNetCore.HttpOverrides
  • Microsoft.AspNetCore.HttpsPolicy
  • Microsoft.AspNetCore.Identity
  • Microsoft.AspNetCore.Localization
  • Microsoft.AspNetCore.Localization.Routing
  • Microsoft.AspNetCore.Mvc
  • Microsoft.AspNetCore.Mvc.Abstractions
  • Microsoft.AspNetCore.Mvc.Analyzers
  • Microsoft.AspNetCore.Mvc.ApiExplorer
  • Microsoft.AspNetCore.Mvc.Api.Analyzers
  • Microsoft.AspNetCore.Mvc.Core
  • Microsoft.AspNetCore.Mvc.Cors
  • Microsoft.AspNetCore.Mvc.DataAnnotations
  • Microsoft.AspNetCore.Mvc.Formatters.Json
  • Microsoft.AspNetCore.Mvc.Formatters.Xml
  • Microsoft.AspNetCore.Mvc.Localization
  • Microsoft.AspNetCore.Mvc.Razor
  • Microsoft.AspNetCore.Mvc.Razor.ViewCompilation
  • Microsoft.AspNetCore.Mvc.RazorPages
  • Microsoft.AspNetCore.Mvc.TagHelpers
  • Microsoft.AspNetCore.Mvc.ViewFeatures
  • Microsoft.AspNetCore.Razor
  • Microsoft.AspNetCore.Razor.Runtime
  • Microsoft.AspNetCore.Razor.Design
  • Microsoft.AspNetCore.ResponseCaching
  • Microsoft.AspNetCore.ResponseCaching.Abstractions
  • Microsoft.AspNetCore.ResponseCompression
  • Microsoft.AspNetCore.Rewrite
  • Microsoft.AspNetCore.Routing
  • Microsoft.AspNetCore.Routing.Abstractions
  • Microsoft.AspNetCore.Server.HttpSys
  • Microsoft.AspNetCore.Server.IIS
  • Microsoft.AspNetCore.Server.IISIntegration
  • Microsoft.AspNetCore.Server.Kestrel
  • Microsoft.AspNetCore.Server.Kestrel.Core
  • Microsoft.AspNetCore.Server.Kestrel.Https
  • Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions
  • Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets
  • Microsoft.AspNetCore.Session
  • Microsoft.AspNetCore.SignalR
  • Microsoft.AspNetCore.SignalR.Core
  • Microsoft.AspNetCore.StaticFiles
  • Microsoft.AspNetCore.WebSockets
  • Microsoft.AspNetCore.WebUtilities
  • Microsoft.Net.Http.Headers

Upvotes: 4

Omar AMEZOUG
Omar AMEZOUG

Reputation: 998

You need to add a framework reference to asp.net core. See the migration guide docs for details See the migration guide docs for details

Upvotes: 4

Vaccano
Vaccano

Reputation: 82291

I had to add a normal assembly reference to Microsoft.AspNetCore.Http.Abstractions and Microsoft.AspNetCore.Mvc.Abstractions.

I also needed to add the NuGet Package Microsoft.AspNetCore.Http.Features.

Upvotes: 2

Related Questions