无法绑定数组
Can't bind array
[HttpPost("notify")]
public async Task<IActionResult> Notify([FromBody] int [] ids)
{
return Ok();
}
请求负载:
{ ids: [1, 2, 3]}
ids
参数为空。
如果我把 ids
改成 object
,它的具体类型是 JObject
.
我错过了什么?
问题中的有效负载是一个名为 ids
的 属性 对象,但签名是针对数组的。因此,我将 Javascript 更改为直接 post 一个(匿名)数组...
axios.post("lalala", this.props.items.map(function (s) { return s.id }))
[HttpPost("notify")]
public async Task<IActionResult> Notify([FromBody] int [] ids)
{
return Ok();
}
请求负载:
{ ids: [1, 2, 3]}
ids
参数为空。
如果我把 ids
改成 object
,它的具体类型是 JObject
.
我错过了什么?
问题中的有效负载是一个名为 ids
的 属性 对象,但签名是针对数组的。因此,我将 Javascript 更改为直接 post 一个(匿名)数组...
axios.post("lalala", this.props.items.map(function (s) { return s.id }))