我想知道为什么我的控制器不识别整数数组,而是识别整数的对象文字。
C#:控制器:
[HttpGet]
public ActionResult Index(Model search)
型:
public class Model {
public int[] MyList {get; set;}
}
JavaScript:
model.myList = [0, 1]; //null at controller
model.myList = {0, 1}; //controller recognizes this
这是怎么回事?
这可能有助于提供有关 MVC 如何翻译和处理数组、字典对象等的信息 http://www.hanselman.com/blog/ASPNETWireFormatForModelBindingToArraysListsCollectionsDictionaries.aspx
通过将[HttpGet]
更改为[HttPost]
来解决