Click here to Skip to main content
14,869,895 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
I am using PagedList in a fully functional pager and it is generating the query string for the indexed pages as expected. 

I wanted to know if there is a way the URL could be customized to eliminate the query string and add another Route parameter instead.
The following is my View :- 
    @model PagedList.Core.IPagedList<ActionAugerMVC.Models.Review>
    @using PagedList.Core.Mvc;
    @addTagHelper *, PagedList.Core.Mvc

    <div id='Paging' style="text-align:center">
         Page @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber) of @Model.PageCount
         <pager class="pager-container" list="@Model" 
                asp-action="Index" asp-controller="Review" />

And here is my Controller Action :-

public IActionResult Index(int? page)
    int pageSize = 10;
    int pageIndex = 1;
    pageIndex = page.HasValue ? Convert.ToInt32(page) : 1;

    var review = unitOfWork.ReviewRepository.GetAll();
    return View(review.OrderByDescending(m=> m.Date).ToPagedList(pageIndex,pageSize));

The current URL looks like this :-

And I want it to look like this :-


Any assistance would be appreciated, as I am still new this !
Thanks once again !

What I have tried:

I have tried to look into the implementation and documentation of PagedList to see how I can override it. I did discover that all the pages were being generated as tags with the quyerystring appended to it, so I was trying to figure out a way to undo that.
Updated 14-Apr-18 6:05am

1 solution

it may help :

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900