Web API : array is returned with a zero length from Get

时间:2018-11-16 21:45:37

标签: c# asp.net-web-api asp.net-core

I'm new to Web API and I'm trying to pass an array of integers back from my Get method. Surprisingly, it was working okay when I did it on my work PC but when I re-wrote it on my home PC, it is coming as a zero length array. I have checked this question and all looks good, but there's something I am missing.

[HttpGet]
[Route("test")]
public ActionResult<string> Test([FromQuery] int[] productIds)
{
    //code here
}

From Url:

https://localhost:44389/api/myController/test?productIds=1&productIds=2&productIds=3&productIds=4&productIds=5

It catches the route, but when I check this in debugger, productIds.Length is zero. Please indicate what's wrong with my url/code.

0 个答案:

没有答案