加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net-mvc-3 – 找不到布局页面“{path}”

发布时间:2020-12-16 00:27:32 所属栏目:asp.Net 来源:网络整理
导读:我们刚刚获得了一个新的Windows 2008 R2服务器,我正在使用Razor View Engine在IIS 7.5中设置一个MVC 3站点。当我访问默认路由时,我收到一个奇怪的错误。 The layout page “~/Views/Shared/_Layout.cshtml” could not be found at the following path: “
我们刚刚获得了一个新的Windows 2008 R2服务器,我正在使用Razor View Engine在IIS 7.5中设置一个MVC 3站点。当我访问默认路由时,我收到一个奇怪的错误。

The layout page
“~/Views/Shared/_Layout.cshtml” could
not be found at the following path:
“~/Views/Shared/_Layout.cshtml”.

这是奇怪的,因为我明确地从/views/home/index.cshtml中设置布局:

@{
  Layout = "~/Views/Shared/_Layout.cshtml";
}

我有100%确定文件系统中存在/views/shared/_layout.cshtml。这是一个截图。

如果我删除了Layout =“?/ Views / Shared / _Layout.cshtml”;从我看来,该页面将自己呈现/home/index.cshtml的内容(没有_Layout.cshtml的任何代码)。我也尝试使用_ViewStart.cshtml设置布局。

任何人都知道为什么MVC将无法“找到”布局文件?当在内置的视觉工作室的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() +159
   System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +335
   System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +62
   System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +20
   System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +54
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +453
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step,Boolean& completedSynchronously) +371

解决方法

似乎你可能有一个权限问题。使用您提供的信息,似乎最可能的原因是无法找到_Layout.cshtml文件。

使用Server 2008和IIS 7,应用程序池具有用于ACL的自己的身份(命名为IIS AppPool {App Pool Name}),这些身份是IIS_IUSRS组的一部分。此外,您的默认inetpub / wwwroot目录将具有IIS_ISRS组的读取权限。所以,如果你没有获得你需要的权限,我会认为App Pool实际上并没有正确的身份运行。

身份可能不正确的一个原因是匿名认证用户身份的设置。进入站点(或整个服务器)的验证控制,并编辑匿名验证规则作为应用程序池标识运行。

这有点猜测,但似乎是this fellow had nearly the exact same issue。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读