Add support json fields in multipart-form requests.
$ dotnet add package Stio.JsonMultipartFormDataSupportMorasiu's project is taken as a basis.
The main difference from the original source is reading the json body from Request.Form.Files.
services.AddJsonMultipartFormDataSupport(JsonSerializerChoice.SystemText);
public class MyWrapper
{
[Required]
public IFormFile File { get; set; } = null!;
[FromJson, Required]
public MyJson Json { get; set; } = null!;
}
and then add to your controller
[HttpPost]
public IActionResult Post([FromForm] MyWrapper request)
{
return this.Ok();
}