-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Description
Is there an existing issue for this?
- I have searched the existing issues
Is your feature request related to a problem? Please describe the problem.
ASP.NET Core currently does not reliably support binding multipart/form-data requests that contain both file uploads and complex JSON payloads.
This is a very common requirement in modern web apps (forms with file uploads + metadata), but the built-in model binder does not deserialize JSON multipart sections into complex objects unless developers manually write custom code, custom binders, or manually parse JSON strings.
Other major backend frameworks support this out-of-the-box:
NestJS / Express (Node.js) → @RequestPart() auto-binds JSON + file
Django REST Framework (Python) → JSON inside multipart binds correctly
Laravel (PHP) → JSON inside multipart is automatically parsed
Spring Boot (Java) → @RequestPart reliably binds complex JSON + files
ASP.NET Core is currently the only major backend that does not provide a first-class solution for this scenario.
Describe the solution you'd like
Please add first-class support for binding multipart/form-data where:
--boundary
Content-Disposition: form-data; name="payload"
Content-Type: application/json
{ "name": "Example", "nested": { "a": 1 } }
--boundary
Content-Disposition: form-data; name="file"; filename="test.pdf"
Content-Type: application/pdf
…binds cleanly to:
public record RequestDto
{
public IFormFile File { get; init; }
public PayloadModel Payload { get; init; }
}
Without requiring:
Custom binders
Manual MultipartReader parsing
JSON-as-string
Custom input formatters
A clean, built-in solution would bring ASP.NET Core in line with other modern backend frameworks and significantly improve developer experience.
Additional context
Existing issues
There are multiple past issues/discussions indicating this gap:
#4868 – Issue with multipart/form-data and JSON deserialization
https://github.com/dotnet/aspnetcore/issues/4868
Marked “Needs: Design”, but not implemented.
#29778 – Improve model binding to form-data JSON
https://github.com/dotnet/aspnetcore/issues/29778
Closed but not implemented. Suggestion was to auto-detect JSON in multipart.
Andrew Lock’s detailed writeup:
https://andrewlock.net/reading-json-and-binary-data-from-multipart-form-data-sections-in-aspnetcore/
Demonstrates that the default binder cannot correctly bind JSON inside multipart forms.
These issues go back several years, and many developers face the same limitation.