在MVC中的PagedList.MVC中,搜索模型正在清除第二页请求

我在我的MVC应用程序中使用PagedList.MVC进行分页。首先我在主页上,当我填写搜索栏并提交表单时,它会在搜索方法上发布模型,如下所示。

public ActionResult GetSearchdProperty(int? page,SearchModel objSearch) { var objProperty = db.re_advertise.OrderBy(r => r.id); return View("SearchedProperty", objProperty.ToPagedList(pageNumber: page ?? 1,pageSize: 2)); } 

因此,此重定向到搜索标准结果的搜索页面。 现在,当我点击PagedList.MVC分页的第二页时,会调用相同的方法,但此时我的SearchModel为空,或者说空白但是我希望我的搜索模型在从分页开始的所有页面请求时都是如此。 那我该怎么做呢?

我试过在VieBag搜索模型,但我没有开始如何在分页请求中从视图包发送模型。 我不知道如何在Html.PagedListPager传递模型

 @Html.PagedListPager(Model, page => Url.Action("GetSearchdProperty", "SearchProperty", new { page })). 

编辑

 public class SearchModel { public string search_text { get; set; } public string min_area { get; set; } public string max_area { get; set; } public string min_price { get; set; } public string max_price { get; set; } public string bedroom { get; set; } } 

在视图模型中为IPagedList添加属性,然后返回模型,以便将搜索/filter值添加到URL

 public class SearchModel { public string search_text { get; set; } public string min_area { get; set; } .... IPagedList Items { get; set; } } public ActionResult GetSearchdProperty(int? page, SearchModel model) { model.Items = db.re_advertise.OrderBy(r => r.id).ToPagedList(pageNumber: page ?? 1,pageSize: 2)); return View("SearchedProperty", model); } 

并在视图中

 @model SearchModel .... @Html.PagedListPager(Model.Items, page => Url.Action("GetSearchdProperty", "SearchProperty", new { page, search_text = Model.search_text, min_area = Model.min_area, .... }))