Search code examples
asp.net-core-mvc.net-8.0iformfile

IFormFile not supported


To use IFormFile, we have to install Microsoft.AspNetCore.Http package, but it is deprecated in .NET 8. How to solve this problem?

I tried to add IFormFile to upload an image. But to add IFormFile, I need to reference Microsoft.AspNetCore.Http, but it is deprecated in .Net 8.

I also tried to install Microsoft.AspNetCore.Http.App, but it is throwing an error

The package Microsoft.AspNetCore.App.Ref 8.0.4 has a package type DotnetPlatform that is incompatible with this project


Solution

  • When I'm creating the .NET 8 ASP.NET MVC project the Visual Studio automatically adds reference to the Microsoft.AspNetCore.App shared framework and this is enough to use the IFormFile in my project. I'm not receiving any deprecating messages.

    This interface declared in the Microsoft.AspNetCore.Http namespace that is part of the Microsoft.AspNetCore.App shared framework.

    For an additional information see Use the ASP.NET Core shared framework