Description
Describe the bug
When i trying to post form with sublist of images models with IFormFile properties, the program starts to hang!
see the screen
To Reproduce
Steps to reproduce the behavior:
- Using this version of ASP.NET Core '2.2'
- Run this code
public class CategoryCreateModel
{
public string Id { get; set; }
public string Name { get; set; }
public int Priority { get; set; }
public string Abbr { get; set; }
public string Description { get; set; }
public string LinkName { get; set; }
public string ParentId { get; set; }
// here error binding
public IList<AppImageEditModel> Images { get; set; }
}
//uploaded images sub collection
public class AppImageEditModel
{
public string Id { get; set; }
public int Priority { get; set; }
public string Name { get; set; }
public string ImageUrl { get; set; }
// if class contains IFormFile prop, hapends binding bug
public IFormFile AppImageFile { get; set; }
public AppImageType ImageType { get; set; }
public bool IsMain { get; set; }
}
// in controller action:
[HttpPost]
public async Task<IActionResult> Create(CategoryCreateModel model)
{
if (ModelState.IsValid)
{
await Mediator.Send(model);
return RedirectToAction("Index");
}
return View(model);
}
No errors thrown, but frease executing:
operative memory encreases from 100 megabytes to 3-4 gigabytes!!!
Screenshots when I submit form:
Expected behavior
The execution is not come to action method and hangs
Binding in razor inside the form:
<form asp-action="Create" enctype="multipart/form-data">
...
<input type="text" name="Images[0].Name" id="Images_0__Text" />
<input type="file" name="Images[0].AppImageFile" id="Images_0__AppImageFile" />
<input type="text" name="Images[1].Name" id="Images_1__Text" />
<input type="file" name="Images[1].AppImageFile" id="Images_1__AppImageFile"/>
Additional context
if you delete the property public IFormFile AppImageFile
from class AppImageEditModel
, the program will work well!