Asp.net 如何使用Html.PagedListPager保留URL参数

Asp.net 如何使用Html.PagedListPager保留URL参数,asp.net,.net,asp.net-mvc,razor,Asp.net,.net,Asp.net Mvc,Razor,我是新的Html.PagedListPager,并试图在我的项目中使用它。这似乎很有用,但我有一个问题要解决 当我使用下面的代码时,一切都按预期进行。但当我用下面的代码单击其中一个页码时,它会清除所有URL参数 @Html.PagedListPager(Model, Page=> Url.Action("Products", new { Page, sortOrder = ViewBag.CurrentSort, currentFilter = ViewBag.CurrentFilter

我是新的Html.PagedListPager,并试图在我的项目中使用它。这似乎很有用,但我有一个问题要解决

当我使用下面的代码时,一切都按预期进行。但当我用下面的代码单击其中一个页码时,它会清除所有URL参数

@Html.PagedListPager(Model, Page=> Url.Action("Products", new { Page,  sortOrder = ViewBag.CurrentSort, currentFilter = ViewBag.CurrentFilter }), PagedListRenderOptions.ClassicPlusFirstAndLast)
当我单击其中一个页面时,我会从URL中丢失类别和品牌值

http://localhost:53307/Home/Products?Page=2&Category=Steel&Brand=BMW
此url将更改为

http://localhost:53307/Home/Products?Page=2
如何保持品牌和品类价值?提前谢谢

@Html.PagedListPager(Model, page => Url.Action("Products",
                            new { page, sortOrder = ViewBag.CurrentSort,  Category = ViewBag.Category, Brand = ViewBag.Brand }))
在控制器动作中:

 public ActionResult Products(string SortOrder, string Category,sting Brand, int? Page)
{
            ViewBag.CurrentSort = SortOrder;
            ViewBag.Category= Category;
            ViewBag.Brand= Brand;
 }

您的代码中没有与类别和品牌相关的内容-您添加的唯一参数是sortOrder和currentFilter