我在Windows 2008 R2服务器上运行IIS下的MVC5网站。该网站工作正常几个小时,然后我开始看到错误消息说
The layout page "~/Views/Shared/Master.cshtml"
could not be found at the following path:
"~/Views/Shared/Master.cshtml".
如果我重新启动不是最佳的网站,则错误消失。关于这里可能会发生什么的任何想法?该网站确实使用异步控制器,这可能导致某些权限问题,即线程无权访问该文件?
答案 0 :(得分:1)
确保在~/Views/_ViewStart.cshtml
文件中设置了正确的路径:
@{
Layout = "~/Views/Shared/_Layout.cshtml";
}
您好像已经设置了这样的布局:
@{
ViewBag.Title = "title";
Layout = "_Layout";
}
您需要将布局的位置指定为绝对路径:
@{
ViewBag.Title = "title";
Layout = "~/Views/Shared/_Layout.cshtml";
}