我正在使用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.有人可以帮我解决这个问题吗?
答案 0 :(得分: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"}
]}