George Mavritsakis
George Mavritsakis

Reputation: 7083

Asp.net Core 1.1 HttpGet FromQuery complex model binding not working

Having this model:

public class PagingParameters
{
    public int PageIndex { get; set; }
    public int PageSize { get; set; }
}

Using the following controller action:

[HttpGet]
public object Query([FromQuery] PagingParameters query)
{
    return null;
}

Sending the following data: enter image description here

Model data still won't properly bind: enter image description here

Is there something missing here ?

Upvotes: 1

Views: 515

Answers (1)

Chris Pratt
Chris Pratt

Reputation: 239260

You're sending a dictionary, not an object. In other words, instead of query[PageIndex], you need query.PageIndex, or simply just PageIndex.

Upvotes: 1

Related Questions