Closed neilmulhy closed 1 year ago
Any response / workaround for me on the above please?
I've found the reason why this didn't work, it was because my route didn't include the page parameter.
[Route("/foopath/{fooGuid}/foosubpath/foo")]
[Route("/foopath/{fooGuid}/foosubpath/foo/{page:int}")] //allow the PagedListPager to find this route.
Once I added this in, the Html.PagedListPager work as expected.
The PagedListPager does respect route attributes.
Describe the bug When I have a route attribute that contains a parameter (i.e.
[Route("/foopath/{fooGuid}/foosubpath/foo")]
), the route isn't getting picked up by Html.PagedListPager in the pager links, which results in an invalid URL structure for my application.Url.Action on its own, however, does pick up the route attribute, providing the correct URL structure.
To Reproduce Steps to reproduce the behavior: 1) Create an attribute route on a controller action as below:
2) Enter the following as the pager partial:
3) Notice how the links generated by Html.PagedListPager don't respect the route attribute but Url.Action does: a) The page links generated are in the unexpected format -
/foocontroller/foo?fooGuid=d9e2668c-9e47-4a78-8ef2-97de2c7ca6bd&page=2&numItemsPerPage=10
b) However, Url.Action gives me the expected URL -/foopath/d9e2668c-9e47-4a78-8ef2-97de2c7ca6bd/foosubpath/foo?numItemsPerPage=10
Useful Screenshot
NOTE: The URL at the bottom of the image is what is displayed when I hover over the page 2 link in the pager.
Expected behavior I'd expect using Html.PagedListPager would work in the same way Url.Action does but with the additional page parameter.
Desktop (please complete the following information):
Additional Context I'm using version 8.4.7 of X.PagedList.
Also, I'm using the following route config in startup.cs:
Question Are you able to offer me a workaround for this issue or is there something further I can do to get this working?