I have a controller
[HttpPost]
public async Task<IActionResult> Report([FromBody][FromForm] ReportViewModel request)
{
var x = request.StartDate; // binds data
var y = request.Pager.RowsPerPage; // always NULL
}
The ReportViewModel is
public class ReportViewModel : IEntity, IResponse
{
public string DateRange { get; set; }
public Pager Pager { get; set; }
}
public class Pager
{
public int CurrentPage { get; set; }
}
I am calling the Controller using AJAX, this is what i am sending from UI
{"Pager.RowsPerPage":"1","Pager.CurrentPage":"2","StartDate":"2021-11-08T17:25:21.243Z"}
I've tried to create the Pager object on ReportViewModel constructor but no luck.
What can be the issue?
Thanks.