@Html.PagedListPager can't be found

Jones picture Jones · Nov 23, 2017 · Viewed 10.1k times · Source

I have a ASP.NET.CORE 2.0 application and I want to add paging to my site. I started with Troy Goode PagedList but I got the same error and I went to try the X version and still got the same results.

Reference to type 'HtmlString' claims it is defined in 'System.Web', but it could not be found
@Html.PagedListPager((IPagedList)Model, page => Url.Action("Index", new { page }))

I can't even find in intellisense the method @Html.PagedListPager UPDATE: It doesn't work on a brand new empty project

@using X.PagedList.Mvc; @*import this so we get our HTML Helper*@
@using X.PagedList; 
@model IPagedList<StecajneObjave.Models.ViewModels.ObjavaViewModel>



<p>
     <a asp-action="Create">Create New</a>
</p>
    <table class="table">
   <tbody>
@foreach (var item in Model) {
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.DatumObjave)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.NazivStecajnogDuznika)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.OIBStecajnogDuznika)
        </td>

        <td>
            @Html.ActionLink("Delaji", "Details", new { id = item.Id }) 
        </td>
    </tr>
}
   </tbody>
  </table>

<h3>Minimal Paging Control w/ Page Count Text</h3>
@Html.PagedListPager((IPagedList)Model, page => Url.Action("Index", new { page }))

I have tried reinstalling nuget packages, cleaning and rebuilding the solution but nothing seems to work. What am I missing here?

Answer

kobowo picture kobowo · Jun 12, 2018

The answers above didn't help me but I found a solution that might also help others.

Change to this:

@using X.PagedList.Mvc.Core

I also had a using statement that was using @using X.PagedList.Mvc only. I don't get why the other user got downvoted because it works.