命名空间中的MVC 3的Razor视图未找到 [英] Namespace not found in MVC 3 Razor view

查看:578
本文介绍了命名空间中的MVC 3的Razor视图未找到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我增加了PagedList我的看法和松散按照此<一个href=\"http://www.asp.net/entity-framework/tutorials/sorting-filtering-and-paging-with-the-entity-framework-in-an-asp-net-mvc-application\">Tutorial.我已经安装使用的NuGet的PagedList参考,建立我的控制器如下:

I am adding a PagedList to my view and loosely following this Tutorial. I have installed the PagedList reference using Nuget, set up my controller as follows

public ViewResult Index(int page = 1)
    {
        List<Part> model = this.db.Parts.ToList();
        const int pageSize = 20;
        return View(model.ToPagedList(page, pageSize));
    }

和在上面写了我用下面的模型视图

And written my view with the following model at the top

@model PagedList.IPagedList<RIS.Models.Part>

当我运行页面,我得到了以下错误

When I run the page I get the following error

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属性设置为真,我曾尝试包括视图名称空间\\ Web.Config中在我的特定的区域。我还能做些什么来让浏览体验的命名空间?

The PagedList dll is being properly loaded in my controller because when I take it out of my view everything works as expected. The CopyLocal property is set to 'True' and I have tried including the namespace in the Views\Web.Config in my specific Area. What else can I do to make the View see the Namespace?

推荐答案

有些事情搞砸了我的整个项目。我创建了一个新的项目,并在复制的重要项目,这一切工作了。我不知道在所有的什么是错的我原来的项目。

Something is messed up with my overall project. I created a new project and copied the important items over and it all works now. I am not sure at all what is wrong with my original project.

这篇关于命名空间中的MVC 3的Razor视图未找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆