[英]Passing complex javascript object to controller. List of objects are always 0
I have a object that I am trying to pass to my C# controller. 我有一个要传递给C#控制器的对象。 All the properties get populated except the list I have is always count =0.
除了我拥有的列表始终为= 0之外,所有属性均已填充。 I have tried setting the header to content-type/json and Json.stringify.
我尝试将标头设置为content-type / json和Json.stringify。 Also for testing I am returning the product list from another call so I know that returns a list of products to my view that is formatted correctly.
另外,为了进行测试,我还从另一个调用返回了产品列表,所以我知道这会返回格式正确的产品列表到我的视图中。
example for creating request 创建请求的示例
var request =
'Id':null,
...
... rest of data is here standard properites
...
'Products':productlist
for product list I am currently using the return value from a call that returns a List 对于产品列表,我当前正在使用返回列表的调用的返回值
return $http.post('api/Enty/Save', request )
.error(function (data, status, headers, config) {
errorLog('error: ' + data);
});
public class Person:IPerson
{
[Required]
public int Id { get; set; }
[MaxLength(90)]
public String Address1 { get; set; }
[MaxLength(90)]
public String Address2 { get; set; }
[MaxLength(40)]
public String Address3 { get; set; }
[MaxLength(40)]
public String City { get; set; }
[MaxLength(2)]
public String State { get; set; }
[MaxLength(40)]
public String Province { get; set; }
[MaxLength(10)]
public String Zip { get; set; }
public IList<IProduct> Products { get; set; }
}
[HttpPost()]
public Response Save(person r)
{}
UPDATE 更新
If I make it List instead of IList it works. 如果我将其设为List而不是IList,则它可以工作。 Any ideas why?
有什么想法吗?
Turns out the issue was not the Ilist but the Iproduct. 原来问题不是Ilist,而是Iproduct。 I just changed to a concrete class for that property
我只是改成了那个财产的具体课程
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.