【发布时间】:2015-10-23 23:23:32
【问题描述】:
数据模型
public class Foo
{
public string Id { get; set; }
public string Title { get; set; }
}
Web API 2 控制器
[Route("api/UpdateFoo")]
public IHttpActionResult UpdateFoo(List<Foo> Foos)
{
}
JS
// here I need to create fooData which is list of foo
var fooData = [];
fooData.push({ Title: "title1" });
fooData.push({ Title: "title2" });
$.ajax({
method: "POST",
url: "api/UpdateFoo",
data: fooData
}).done(function (result) {
// good
}).fail(function(xhr) {
alert(xhr.responseText);
});
我在这里缺少什么?在提琴手看起来我已经正确发送了 fooData 但是它没有在 Web Api 控制器中收到,我能够输入带有断点的方法但是空列表中的值
【问题讨论】:
标签: jquery ajax asp.net-web-api