无法在以下路径中找到:“〜/ View / Shared / _Layout.cshtml”。 [英] could not be found at the following path: "~/View/Shared/_Layout.cshtml".

查看:956
本文介绍了无法在以下路径中找到:“〜/ View / Shared / _Layout.cshtml”。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在mvc项目的索引页面中呈现页面布局。这是代码:

_ViewStart.cshtml

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





index.cshtml

 @ {
布局= 〜/ Views / Shared / _Layout.cshtml;
}





_Layer.cshtml页面存在于给定文件夹中,即共享文件夹。但是当我运行项目时,我给出了一个错误。

 服务器 错误 '/'应用程序中。 
布局 page 〜/ View / Shared / _Layout.cshtml 找到 path:〜/ View / Shared / _Layout.cshtml。
描述: 未处理 exception 发生 <-span> = 执行 当前 web request review stack trace for 更多 信息 关于 错误 其中 it originated 代码

异常 详情: 系统 Web HttpException: layout page 〜/ View / Shared / _Layout.cshtml可以 找到 path:〜/ View / Shared / _Layout.cshtml。







i试图使用〜/ shared / _Layout.cshtml语法。但是使用

有人可以告诉我我需要做什么。

解决方案

将_Layout.cshtml文件移动到View主文件夹:)

i am trying to render page layout in my index page in mvc project. here is the code:
_ViewStart.cshtml

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



index.cshtml

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



the _Layer.cshtml page exists in the given folder i.e is shared folder. but when i run the project i gives an error.

Server Error in '/' Application.
The layout page "~/View/Shared/_Layout.cshtml" could not be found at the following path: "~/View/Shared/_Layout.cshtml".
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: The layout page "~/View/Shared/_Layout.cshtml" could not be found at the following path: "~/View/Shared/_Layout.cshtml".




i have tried to use ~/shared/_Layout.cshtml syntax. but of use
Can somebody please tell me what i need to do.

解决方案

Move _Layout.cshtml file into View main folder :)


这篇关于无法在以下路径中找到:“〜/ View / Shared / _Layout.cshtml”。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆