Here's my controller:
public class TagsController : Controller
{
public ActionResult Attach(TagsAttach model)
{
// ...
}
}
Here are my view-models:
public class TagsAttach
{
public int GroupID { get; set; }
public List<Tag> Tags { get; set; }
}
public class Tag
{
public int ID { get; set; }
}
And here's the Javascript code that I'm using to attempt to submit my data:
var data = {
GroupID: 12,
Tags: []
};
data.Tags.push({ ID: 3 });
data.Tags.push({ ID: 4 });
$.push('/Tags/Attach', data);
However, when I debug my controller action, I find everything is there except for the ID values in each of the Tag objects.
Thus, my 'model' parameter looks like this:
model
GroupID 12
Tags
Tag
ID 0
Tag
ID 0
Why is this? What do I have to do for ASP.NET MVC to bind my ID values correctly?
(Note: what I'm doing seems pretty much exactly the same as this. So why isn't it working for me?)