'Problem with model binding in file input type

I'm working on an Asp.Net Core MVC project. In my model, I have an IFormFile property. When I use a simple input tag It works fine, But on using the file input plugin in this URL, It fails to do the model binding on the IFormFile property! Has anyone faced the same problem?

Here is the input tag

<input id="input-b2" name="input-b2" type="file" class="file" data-show-preview="false" asp-for="ImageFile" accept="image/jpeg">

The IFormfile property has annotations of Required, Display, and NotMapped



Solution 1:[1]

If you use name attribute, it will override the asp-for generated name. For your scenario, you just need to remove it:

<input id="input-b2" type="file" class="file" data-show-preview="false" asp-for="ImageFile" accept="image/jpeg">

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Rena