我做了一个ajax POST调用,
$scope.clientList = [];
$http({
method: 'POST',
dataType: 'json',
contentType: "application/json; charset=utf-8",
url: "https://localhost/api/Client",
data: JSON.stringify($scope.user)
}).success(function (response, status, headers, config) {
$scope.clientList = response.data;
}). error(function (data, status, headers, config) {});
现在是我的控制器,
public List<Customer> Post([FromBody] Customer customer)
{
customer.Count = 0;
lstCustomer.Add(customer);
return lstCustomers;
}
客户类
public class Customer
{
public string CName{ get; set; }
public int Count{ get; set; }
}
但我的返回数组不包含新添加客户的count参数本身。 它只是没有采取零值。
我怎样才能做到这一点?