In my ASP.MVC I have following models:
public class MySubModel
{
public int Id { get; set; }
}
public class MyModel
{
public List<MySubModel> Items { get; set; }
}
On the client side I'm using jQuery.ajax() to send data to the server via POST request. My problem is that each Id in the list has it default value (0).
After debugging through DefaultModelBinder I figured out that ASP.MVC expect keys like this:
Items[0].Id
while jQuery send
Items[0][Id]
Is there a way to customize this jQuery behavior?
P.S. It's look like I can use JSON.stringify() on the client and some JSON parser on the server but it's a hack for me. Is there a better way?