0

我正在使用ASP.NET MVC 4. 我正在尝试将对象数组发送到控制器。我的观点包含:

<input type="hidden" id="1" name="Persons" value='[
 {"Id":1,"Name":"Abc","Description":"this is desc"},
 {"Id":2,"Name":"def","Description":"this is desc"},         
 {"Id":4,"Name":"ghi","Description":"this is desc"}]'
/>

我的控制器动作是这样的:

public ActionResult create(List<Person> Persons)
{
  //Here the Persons count is always 0, why ?
} 

当我发布我的表格时,我总是得到人数 0。有人可以帮我解决这个问题吗?

4

1 回答 1

0

尝试将您的输入值更改为:

{Persons: [
    {"Id":1,"Name":"Abc","Description":"this is desc"},
    {"Id":2,"Name":"def","Description":"this is desc"},         
    {"Id":4,"Name":"ghi","Description":"this is desc"}
]}
于 2013-04-21T06:35:35.897 回答