robert_rg
robert_rg

Reputation: 297

PageList Cannot convert method group 'pagedlistpager' to non-delegate type in ASP.NET Core MVC 2.1

Trying to add paging to users in my ASP.NET Core MVC 2.1 web app. Everything seems to be working except @Html.PagedListPager - I get an error:

Cannot convert method group 'pagedlistpager' to non-delegate type 'object'.

Also I noticed under Dependencies > NuGet > PagedList.Mvc > PagelistList(1.17.0) a yellow exclamation mark. I wonder if pagelist is supported in core 2.1? I tried to downgrade it and update it and it still has the mark. Is there a solution or work around?

@Html.PagedListPager (Model, page => Url.Action("Index",
     new { page, sortOrder = ViewBag.CurrentSort, currentFilter = ViewBag.CurrentFilter }))

Upvotes: 2

Views: 804

Answers (2)

robert_rg
robert_rg

Reputation: 297

X.PagedList.MVC.Core worked perfectly I used the same exactly code and documentation on learn.microsoft.com to get it to work. When I used

@model X.PagedList.PagedList<MyProject.Models.ApplicationUser>
@using MyProject.Utility
@using X.PagedList.Mvc.Core
@using X.PagedList;

In my view the error went away

Upvotes: 2

DavidG
DavidG

Reputation: 118947

That error is happening because there is a space before the opening ( meaning Razor treats it as @Html.PagedListPager.

Also as pointed out, that package hasn't been updated since 2013 so is not supported in .NET Core. The official site for that package suggests you use X.PagedList.Mvc.Core instead.

Upvotes: -1

Related Questions