我有下面这个Javascript类,我想传递给一个ASP.NET MVC控制器。
var postParams = {
attributes : [
{
name : '',
description: '',
attributeType : '',
value : ''
}
]
};
postParams.attributes[0] = new Object();
postParams.attributes[0].name = "test";
postParams.attributes[0].description = "test";
postParams.attributes[0].attributeType = "test";
postParams.attributes[0].value = "test";
这是我调用控制器方法的方式:
var actionURL = "@Url.Action("Save", "Catalog")";
$.ajax({
type: "POST",
url: actionURL,
data: postParams ......
在控制器侧,我声明了一个ViewModel如下:
public class AttributeViewModel
{
public string name { get; set; }
public string description { get; set; }
public string attributeType { get; set; }
public string value { get; set; }
}
我的控制器Save方法声明如下:
public JsonResult Save(AttributeViewModel[] attributes)
当我执行时,属性值始终为null。
有什么想法吗?不确定如何开始调试。
[JsonFilter(Param = "mydata", JsonDataType = typeof(AttributeViewModel[]))]
吗? - touinta找不到类型或命名空间名称“JsonFilterAttribute”
- touinta