PagedList.Core.Mvc PagedListPager Html extension in .Net Core is not there

lucas picture lucas · Jan 7, 2017 · Viewed 12.7k times · Source

It seems like the PagedList.Core does not contain the extension method for Html helper, so I cannot use the code below:

@Html.PagedListPager(Model, page => Url.Action("Index", new { page }), PagedListRenderOptions.MinimalWithItemCountText)

I was able to successfully implement the paging in previous version of MVC, but it does not work in ASP.Net Core. Below I have attached IL Dasm reference. Am I missing something, or is there any other way to implement that?

PagedList.Mvc:

enter image description here

PagedList.Core.Mvc:

enter image description here

Answer

lucas picture lucas · Jan 7, 2017

I should follow the Instructions of the new version, it is a little different from previous version. I was able to implement the paging with the following code changes:

Startup.cs:

    public void ConfigureServices(IServiceCollection services)
    {
        services.AddSingleton<IActionContextAccessor, ActionContextAccessor>();
    }

_ViewImports.cshtml:

@addTagHelper *, PagedList.Core.Mvc

And finally to use it, we don't use Html tag helper anymore in .Net Core:

<pager class="pager-container" list="@Model" options="@PagedListRenderOptions.TwitterBootstrapPager" asp-action="Index" asp-controller="ControllerName" />