我将PagedList添加到我的视图中,并松散地遵循这个教程。我使用Nuget安装了PagedList参考,如下设置了我的控制器:
public ViewResult Index(int page = 1)
{
List<Part> model = this.db.Parts.ToList();
const int pageSize = 20;
return View(model.ToPagedList(page, pageSize));
}
我用以下模型编写了我的视图
@model PagedList.IPagedList<RIS.Models.Part>
当我运行页面时,会出现以下错误。
Compiler Error Message: CS0246: The type or namespace name 'PagedList' could not be found (are you missing a using directive or an assembly reference?)
Source Error:
Line 27:
Line 28:
Line 29: public class _Page_Areas_Parts_Views_Part_Index_cshtml : System.Web.Mvc.WebViewPage<PagedList.IPagedList<RIS.Models.Part>> {
当我将PagedList dll从视图中移除后,一切按预期运行,因此在我的控制器中正确加载了它。CopyLocal属性设置为“True”,并尝试在特定区域的Views\Web.Config中包含名称空间。还有什么其他方法可以让视图看到名称空间?