Reputation: 6868
I am trying to bind data in my model posted from postman in my below model:
public class VariantModel
{
public int Id { get; set; }
public List<SubvariantModel> Subvariants { get; set; }
}
public class SubvariantModel
{
public int Id { get; set; }
public string Description { get; set; }
public IFormFile Document { get; set; }
}
Every property is getting populated but only Document
property is coming null as you can see here :
But surprisingly when i inspect http request object i see that file :
This is how i am posting data from POSTMAN :
Code :
[HttpPost]
public void Post([FromForm]VariantModel emp)
{
var d = HttpContext.Request;
}
Can anybody tell me what could be the issue here?
Update :
Upvotes: 7
Views: 2987
Reputation: 465
This is an issue I encountered as well. It is a known issue with nesting IFormFile as a View Model property in .NET Core v2.2.
The fix that worked for me is here.
Upvotes: 1