I have an action method that gets an object called InputObj.
public class InputObj<T>
{
public T Item { get; set; }
public int PageSize { get; set; }
public int PageNumber { get; set; }
}
And the action method is:
[HttpGet]
public ActionResult Search(InputObj<USER> input)
{
and in view I used PagedListPager if the search had results:
@if (ViewBag.Result != null)
{
@Html.PagedListPager((IPagedList)ViewBag.Result, page => Url.Action("Search", new InputObj<USER>
{
Item = Model.Item,
PageNumber = page,
PageSize = Model.PageSize
}))
}
But when I want to go to other pages, The Item
is null
, but PageNumber and PageSize are initialized correctly. In querystring I have
/User/Search?Item=MyApplication.Model.User&PageSize=2&PageNumber=2
It seems we have .toString() here for Item!