我们刚刚获得了一台新的Windows 2008 R2服务器,我正在尝试使用Razor View Engine在IIS 7.5中建立一个MVC 3站点.当我访问默认路由时,我收到一个奇怪的错误.
在以下路径中找不到布局页面"〜/ Views/Shared/_Layout.cshtml":"〜/ Views/Shared/_Layout.cshtml".
这很奇怪,因为我从内部明确设置了Layout,/views/home/index.cshtml
如下所示:
@{
Layout = "~/Views/Shared/_Layout.cshtml";
}
Run Code Online (Sandbox Code Playgroud)
我100%肯定/views/shared/_layout.cshtml
文件系统中存在.这是一个截图.
如果我Layout = "~/Views/Shared/_Layout.cshtml";
从我的视图中删除,页面将自动呈现/home/index.cshtml
所有内容(没有任何代码_Layout.cshtml
).我也试过使用设置布局_ViewStart.cshtml
.
任何人都知道为什么MVC无法"找到"布局文件?在Visual Studio的内置Web服务器中运行时,该网站运行良好.
这是我的堆栈跟踪:
[HttpException (0x80004005): The layout page "~/Views/Shared/_Layout.cshtml" could not be found at the following path: "~/Views/Shared/_Layout.cshtml".]
System.Web.WebPages.WebPageExecutingBase.NormalizeLayoutPagePath(String layoutPage) +204956
System.Web.WebPages.WebPageBase.PopContext() +150
System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +384
System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19() +33
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +784900
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +265
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +784976
System.Web.Mvc.Controller.ExecuteCore() …
Run Code Online (Sandbox Code Playgroud)