I am currently facing an issue with mapping a list of objects in a FormData to my ASP.NET MVC Model class at the controller. I have successfully sent the FormData over to the server-side, but I am unable to bind any value. Can someone provide guidance on how to correctly map the objects? Below is the code snippet I am currently working with:
Update I am still struggling with this problem and any help would be greatly appreciated! Update2 Just to clarify, I am utilizing Vue.js as my client-side framework
Client-side
const formData = new FormData();
formData.append("Product[0].ProductName", "T-Shirt");
formData.append("Product[0].Options.Quantity", "1");
formData.append("Product[1].ProductName", "Shoe");
formData.append("Product[1].Options.Quantity", "2");
Server-side (Controller)
[HttpPost("verifyCart")]
public async Task<IActionResult> verifyCart([FromForm] Product[] products)
{
}
Server-side (Model)
public class Product
{
public string ProductName { get; set; }
public List<Option> Options { get; set; }
}
public class Options
{
public int Quantity { get; set; }
}