IFormFile binding error
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 281
Description
### Describe the bug
I have a model with IFormFIle property and other simple type properties.It could pass to the controller with [ApiController] and [FromForm] successfully.But If I only pass IFormFile property in model,it could not pass data to controller.I find a solution,when I remove [ApiController] and [FromForm],it works.
### To Reproduce
using asp.net core 3.1
Model:
```
public class ProductImageDetailsDto
{
public IFormFile ProductImage { get; set; }
public bool IsDefaultImage { get; set; }
}
```
Controller:
```
[ApiController]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
{
[HttpPut("UpdateProductImagesByProductId/{id}")]
public async Task UpdateProdutImagesByProductId(Guid id,[FromForm]List productImages)
{
return Ok();
}
}
```
SO Reference:
https://stackoverflow.com/questions/65085522/how-to-upload-multiple-files-using-multipart-form-data-media-type-in-net-core-w/65087114
Contributor guide
Assessment
This issue has not been assessed yet.