【问题标题】:View not found in MVC4 / ASP.net 4.5 hybrid application在 MVC4 / ASP.net 4.5 混合应用程序中找不到视图
【发布时间】:2013-07-17 15:18:13
【问题描述】:

我们的主站点是 ASP.net 4.5 并使用 Ektron(一个 .net CMS)我正试图将其变成 MVC4 / Webforms 混合体。
据我所知,我已经正确安装了 MVC4 需要的所有东西,但是当我尝试点击默认的 Home 控制器时,我得到了经典的

[InvalidOperationException: The view 'Index' or its master was not found or no view engine supports the searched locations. The following locations were searched:
~/Views/home/Index.aspx
~/Views/home/Index.ascx
~/Views/Shared/Index.aspx
~/Views/Shared/Index.ascx
~/Views/home/Index.cshtml
~/Views/home/Index.vbhtml
~/Views/Shared/Index.cshtml
~/Views/Shared/Index.vbhtml]

我使用 NuGet 并通过从默认 MVC4 应用程序复制默认控制器、查看和关联的 App_Start 和 Global.asax 文件来安装 MVC4。我还安装了工作正常的 WebAPI(这告诉我路由似乎工作正常,即我可以去 API/Values 并恢复默认值 api 数据就好了)。

该网站作为主网站安装,即不是作为子网站或子应用程序。

我最初认为处理程序部分可能存在问题,因为 Ektron(我们的 CMS)添加了大量处理程序,但已将 web.config 撕开,并且在其中找不到任何问题。我什至尝试用默认 MVC4 应用程序中的那个替换它,并得到了同样的错误。 请注意,我确实必须更改默认 web.config 和自定义的部分。
当我有这个部分时:

      <dependentAssembly>
    <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-2.1.10.0" newVersion="2.1.10.0" />
  </dependentAssembly>

我得到了错误

Could not load file or assembly 'System.Net.Http, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

我查看了该 DLL 的程序集详细信息,发现它是 4.0.0.0 版,所以我将那部分更改为

      <dependentAssembly>
    <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
  </dependentAssembly>

哪个修复了该错误,据我所知是可以的,但我再次遇到上述未找到视图的问题。

任何帮助将不胜感激。

【问题讨论】:

  • 您的视图的实际路径是什么?

标签: asp.net-mvc-4


【解决方案1】:

好吧,我觉得自己很笨。

@SLaks 简单的问题帮助我找到了答案。

我们有一个相当复杂的构建系统。它将 Ektron 基础代码项目(这是一个网站而不是项目)与我们的主项目和类库组合到输出目录中,在本例中 /debug 是我的 IIS 指向的位置。涉及几个步骤,包括在“构建”期间将我们的 Web 项目转换回网站(不要问,这很痛苦,但会加快构建时间)。 无论如何,我们只复制了某些文件类型,而 .cshtml 不在列表中,所以是的,输出调试目录中没有视图文件夹。 . .

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-16
    • 1970-01-01
    相关资源
    最近更新 更多