dotnet/aspnetcore

HttpRequest.Form throws an undocumented System.InvalidOperationException

Open

#49.096 geöffnet am 29. Juni 2023

Auf GitHub ansehen
 (5 Kommentare) (0 Reaktionen) (1 zugewiesene Person)C# (10.653 Forks)batch import
Docsarea-networkingbughelp wantednet8_docathon

Repository-Metriken

Stars
 (37.933 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 16T 9h) (258 gemergte PRs in 30 T)

Beschreibung

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

After upgrading from ASP.NET Core 3.x to ASP.NET Core 6, we found that HttpRequest.Form throws an undocumented System.InvalidOperationException with the message "Incorrect Content-Type: image/png".

System.InvalidOperationException: Incorrect Content-Type: image/png
   at Microsoft.AspNetCore.Http.Features.FormFeature.ReadForm()
   at Microsoft.AspNetCore.Http.DefaultHttpRequest.get_Form()

This seems to only affect image files. Using the same code to read CSV files continues to work.

Expected Behavior

Form object is returned.

Steps To Reproduce

No response

Exceptions (if any)

System.InvalidOperationException

.NET Version

7.0.304

Anything else?

Contributor Guide