dotnet / dotnet/aspnetcore

Improve support for multipart/form-data with complex JSON + file uploads

Open
#64,429 1 comment 3 reactions 0 assignees View on GitHub
area-blazor area-minimal Needs: Design
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 10h
Merged PRs (30d)
281

Description

### Is there an existing issue for this?

- [x] 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

--boundary--
```

…binds cleanly to:

```csharp
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](https://github.com/dotnet/aspnetcore/issues/4868?utm_source=chatgpt.com)

Marked “Needs: Design”, but not implemented.

#29778 – Improve model binding to form-data JSON
[https://github.com/dotnet/aspnetcore/issues/29778](https://github.com/dotnet/aspnetcore/issues/29778?utm_source=chatgpt.com)

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/](https://andrewlock.net/reading-json-and-binary-data-from-multipart-form-data-sections-in-aspnetcore/?utm_source=chatgpt.com)

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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.