.Net Core中的PagedList.Core.Mvc PagedListPager HTML扩展名不存在 [英] PagedList.Core.Mvc PagedListPager Html extension in .Net Core is not there
问题描述
PagedList.Core
似乎不包含Html帮助程序的扩展方法,因此我无法使用以下代码:
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)
我能够在MVC的早期版本中成功实现分页,但是在ASP.Net Core中不起作用.下面附上IL Dasm参考.我是否缺少某些东西,或者还有其他实现方法吗?
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:
PagedList.Mvc:
PagedList.Core.Mvc:
PagedList.Core.Mvc:
推荐答案
我应该遵循新版本的说明,它与以前的版本有些不同.我能够通过以下代码更改来实现分页:
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:
Startup.cs:
public void ConfigureServices(IServiceCollection services)
{
services.AddSingleton<IActionContextAccessor, ActionContextAccessor>();
}
_ViewImports.cshtml:
_ViewImports.cshtml:
@addTagHelper *, PagedList.Core.Mvc
最后要使用它,我们不再在.Net Core中使用Html标记帮助程序:
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" />
这篇关于.Net Core中的PagedList.Core.Mvc PagedListPager HTML扩展名不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!