我不知道,因为当我按角度做一篇文章时,没有填充对象,例如类别或状态。只是产品。 但是请注意,Request.Form列表中的信息就在那里。 活页夹未正确执行。 我在做什么错? 它是任何Web API配置? 我试过通过application/json发送数据,[frombody] ...我没有选择。 在此先感谢。asp.net 5/mvc 6/model binder/angular
var product = {
id: 1,
name: "Name",
categories: [
{ id: 1, name: "name 1" },
{ id: 2, name: "name 2" }
],
status: { id: 1, name: "active" }
};
var config: ng.IRequestConfig;
config = { url: "", method: "POST", headers: { 'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;' } };
self.$http.post("api/produto", $.param(product), config)
.success(function() {
alert("OK");
});
[HttpPost]
public ProductInfo Post(ProductInfo item)
{
return item;
}