PagedList tag helper for ASP.NET Core
-
Install
PagedList.Core.Mvc
package from Nuget. -
Add the following code in
Startup.cs
public void ConfigureServices(IServiceCollection services)
{
// Add framework services.
services.AddMvc();
services.AddSingleton<IActionContextAccessor, ActionContextAccessor>(); // <= Add this
}
- Edit
_ViewImports.cshtml
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
+ @addTagHelper *, PagedList.Core.Mvc
<pager class="pager-container" list="@Model.Tests" options="@PagedListRenderOptions.TwitterBootstrapPager" asp-action="Index" asp-controller="Test" asp-route-keyword="@Model.Keyword" />