c# - 找不到@Html.PagedListPager

标签 c# pagedlist asp.net-core-mvc-2.0

我有一个 ASP.NET.CORE 2.0 应用程序,我想向我的站点添加分页。我从 Troy Goode PagedList 开始,但我遇到了同样的错误,然后我尝试了 X 版本,但仍然得到了相同的结果。

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 }))

我什至无法在智能感知中找到方法 @Html.PagedListPager 更新:它不适用于全新的空项目

@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 }))

我已尝试重新安装 nuget 包、清理和重建解决方案,但似乎没有任何效果。我在这里缺少什么?

最佳答案

上面的答案对我没有帮助,但我找到了一个可能对其他人也有帮助的解决方案。

对此的更改:

@using X.PagedList.Mvc.Core

我还有一个 using 语句,它只使用了 @using X.PagedList.Mvc。我不明白为什么其他用户因为它有效而被否决。

关于c# - 找不到@Html.PagedListPager,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47453508/

相关文章:

c# - 通过属性或 setter 方法的 ASP.NET Core MVC 依赖注入(inject)

c# - 有关如何在 C# 中从 XML 文档中正确提取 DateTime 的一些信息?

带有部分 View 的 AJAX 分页列表

css - MVC PagedList 的自定义 CSS

c# - 更改 PagedList 的生成链接

c# - InvalidOperationException : Cannot resolve scoped service 'Microsoft. AspNetCore.Identity.UserManager .NET 核心 2.0

c# - 无效操作异常 : No IAuthenticationSignInHandler is configured to handle sign in for the scheme: MyCookieAuthenticationScheme

c# - C# 应用程序是否可以与内核驱动程序通信?

c# - 转换为 IEnumerable

c# - "using"语句的EF( Entity Framework )用法