【发布时间】:2015-11-04 01:49:13
【问题描述】:
我正在使用 PagedList.Mvc NuGet 包进行分页,在视图中一切似乎都运行良好,但在我的控制器中发生此错误
'System.Collections.Generic.List<CreateSocial.Models.UserProfiles>' does not contain a definition for 'ToPagedList' and no extension method 'ToPagedList' accepting a first argument of type 'System.Collections.Generic.List<CreateSocial.Models.UserProfiles>' could be found (are you missing a using directive or an assembly reference?)
即使我定义了这样的命名空间:
using PagedList;
using PagedList.Mvc;
我的代码如下所示:
[HttpGet]
public ActionResult Results(SearchViewModel svm, int CurrentPage)
{
const int ResultsPerPage = 50;
List<UserProfiles> results = db.UserProfiles.Where(w => w.FirstName.Contains(svm.SearchStr) || w.LastName.Contains(svm.SearchStr)).ToList();
return View(results.ToPagedList(CurrentPage, ResultsPerPage));
}
我尝试通过包管理器控制台再次删除和添加 PagedList。但我似乎无法修复它。什么可能导致这种情况以及如何解决?希望大家能给点建议。提前致谢!
【问题讨论】:
标签: c# asp.net-mvc namespaces nuget-package pagedlist