Using Asp.Net Core 2.2 I am calling an API using:
products?productsIds=1,2&offset=10&limit=4
But I get the error on model binding for productsIds:
The value '1,2' is not valid.
I tried with productsIds=1
and in that case it works.
And Offset
and Limit
also get the correct values ...
The API model and action are:
public class Request {
public IList<Int32> ProductsIds { get; set; }
public Int32 Limit { get; set; }
public Int32 Offset { get; set; }
}
[ApiController]
public class ProductController : ControllerBase {
[HttpGet("products")]
public async Task<IActionResult> Get([FromQuery]Request request) {
// Action code
}
}
What am I missing?
Update
This is not similar to this Question as the solution proposed in that question uses [FromUri]
.
The attribute [FromUri]
is not available in ASP.NET Core 2.2 ApiController
(Microsoft Docs).