66

I have a .NET 7 Blazor helper library which has been referencing HttpContext from the Microsoft.AspNetCore.Http.Abstractions (2.2.0) nuget. However, this nuget is now flagged as deprecated by Microsoft, thus the Visual Studio Nuget manager shows me warnings for this package reference.

But my .Net7 Blazor app is using Microsoft.AspNetCore.Components.Web (7.0.5) and the root razor page _Host.cshtml exposes the HttpContext property, which I need to pass to a helper method in the above mentioned project.

What am I missing here? If I Browse my way to the HttpContext definition from _Host.cshtml, Visual Studio claims it's declared in Microsoft.AspNetCore.Http.Abstractions (7.0.0.0), which is nowhere to be found?

I also have similar issues with other, related packages. What's the correct way to reference these packages, without warnings? Or what other packages am I to use?

13
  • 20
    Check out the suggested duplicates. In short - remove the link to the nuget and add FrameworkReference element. Also check out this part of docs Commented May 4, 2023 at 14:00
  • 11
    Thank you, unfortunately the FrameworkReference to Microsoft.AspNetCore.App prevents the library from being used from Blazor WASM, so this is not the final answer... Commented May 4, 2023 at 16:52
  • 4
    The way I was able to bypass this depreciation issue is to modify the project file and include the reference to "Microsoft.AspNetCore.App". Reference: https://learn.microsoft.com/en-us/aspnet/core/fundamentals/target-aspnetcore?view=aspnetcore-7.0&tabs=visual-studio#only-support-the-blazor-server-hosting-model Commented Jun 7, 2023 at 15:56
  • 6
    That's what was mentioned in the comments above, but it doesn't work for Blazor WebAssembly. That's why we ended up splitting up libraries for WASM/Server. Commented Jun 8, 2023 at 18:22
  • 1
    @phuzi your link is broken Commented Jul 20, 2023 at 14:11

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.