且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将数组传递给asp net core web api action方法HttpGet

更新时间:2023-02-15 16:27:54

Binding failed for Array parameter is a known issue under Asp.Net Core 2.1 已记录查询字符串中的数组或列表未解析#7712.

Binding failed for Array parameter is a known issue under Asp.Net Core 2.1 which has been recorded Array or List in query string does not get parsed #7712.

对于临时解决方法,您可以像下面这样设置 FromQuery Name Property:

For a tempory workaround, you could set the FromQuery Name Property like below:

        [HttpGet()]
    [Route("ServicesByCategoryIds")]
    public async Task<IActionResult> ServicesByCategoryIds([FromQuery(Name = "ids")]int[] ids)
    {            
        return Ok();
    }