【发布时间】:2020-08-25 05:17:39
【问题描述】:
我有以下 javascript 对象:
var param = {
FilePaths: ['String1', 'String2', 'String3'],
Share: false
}
我的 AngularJS POST 如下:
$http({
method: 'POST',
url: config.apiUrl + '/ImportSubset/Import',
data: param,
headers: {
'Content-Type': 'application/json'
}
}).then(function (response) {
console.log(response);
}, function (error) {
console.log(error);
});
我的 ASP.NET 控制器:
public class ImportSubsetController : Controller
{
public class ImportParam
{
public List<string> FilePaths;
public bool Share;
}
public JsonResult Import(ImportParam param)
{
(...)
}
当我调用导入 API 时,Share 属性通过就好了,但 FilePaths 是 Null。我在这里做错了什么?我尝试使用data: JSON.stringify(param),但仍然以Null 传递。
【问题讨论】:
标签: asp.net angularjs asp.net-mvc asp.net-core asp.net-mvc-5