【问题标题】:How to correclty use Views in different folders. (The view 'Index' or its master was not found or no view engine supports the searched locations)如何正确使用不同文件夹中的视图。 (未找到视图“索引”或其主视图或没有视图引擎支持搜索的位置)
【发布时间】:2015-08-27 11:40:09
【问题描述】:

我的 App 有 3 个大模块,一个给全局管理员,一个给公司管理员,一个给公司用户。

我想把它分成文件夹,在控制器文件夹和视图文件夹中。

当我添加带有脚手架的控制器时。 http://screencast.com/t/zxK5kaWLY

它会自动在views文件夹中创建一个以模型名称命名的文件夹。 http://screencast.com/t/JsSxGjkFw5h3

但是,我想这样组织它,所以我移动了文件 http://screencast.com/t/8n24rU7n2fbI

但是当我尝试运行它时,我得到了这个错误:

The view 'Index' or its master was not found or no view engine supports the searched locations. The following locations were searched:

> ~/Views/Empresas/Index.aspx ~/Views/Empresas/Index.ascx
> ~/Views/Shared/Index.aspx ~/Views/Shared/Index.ascx
> ~/Views/Empresas/Index.cshtml ~/Views/Empresas/Index.vbhtml
> ~/Views/Shared/Index.cshtml ~/Views/Shared/Index.vbhtml

我想这样组织它的原因是因为应用程序很大,每个模块有很多控制器,所以更容易找到。

【问题讨论】:

标签: c# asp.net asp.net-mvc entity-framework razor


【解决方案1】:

您应该使用区域拆分您的应用程序:

Organizing an ASP.NET MVC Application using Areas

【讨论】:

    猜你喜欢
    • 2013-06-23
    • 2013-08-18
    • 1970-01-01
    • 2017-03-09
    • 2015-07-09
    • 1970-01-01
    • 2014-03-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多