gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 14:47:19 26 4
gpt4 key购买 nike

我们刚刚获得了一个新的 Windows 2008 R2 服务器,我正在尝试使用 Razor View 引擎在 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存在于文件系统中。这是一个屏幕截图。

enter image description here

如果我删除 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() +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 组具有读取权限。因此,如果您没有获得所需的权限,我认为应用程序池实际上并没有以正确的身份运行。

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

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

IIS Anonymous Authentication user identity screen

关于asp.net-mvc-3 - 找不到布局页面 "{path}",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6145636/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com