将MVC站点部署到IIS会导致无法找到默认的共享局部视图

Lar*_*ard 2 asp.net iis asp.net-mvc asp.net-mvc-4

我有一个在我的本地IIS上完美运行的站点.

我的所有页面都使用默认的共享局部视图,称为预期_Layout.cshtml.此视图位于我的共享文件夹中.这可以在这里看到:

在此输入图像描述

正如我所料,这完美地运作.

但是,我现在发布我的网站.然后,我的一些页面之外的HomeController结果是:

The view 'Index' or its master was not found or no view engine supports the searched locations. The following locations were searched:
~/Views/Search/Index.aspx
~/Views/Search/Index.ascx
~/Views/Shared/Index.aspx
~/Views/Shared/Index.ascx
~/Views/Search/Index.cshtml
~/Views/Search/Index.vbhtml
~/Views/Shared/Index.cshtml
~/Views/Shared/Index.vbhtml
Run Code Online (Sandbox Code Playgroud)

这当然是正确的,但我希望它能够_Layout.cshtml在我的共享文件夹中搜索,而不是这些文件名.

我该怎么做才能解决它?为什么它适用于我的本地IIS,而不是生产?

Lar*_*ard 6

事实证明问题完全在别的地方.

事实证明,许多旧观点都将"建立行动"设置为"无".这导致我的观点不存在,然后它根本找不到它们.

错误是有道理的,但我没有看到这是实际问题!