默认情况下如何更改布局?
默认情况下,我在_viewstart.cshtml中更改布局,
@{
Layout = "_Layout-empty";
}
但它是布局不起作用的。 _ layout正在工作。
然后,我删除_layout并获取错误:
invalidoperationException:布局视图'_layout'不可能是 位于。搜索以下位置: /Views/home/_layout.en.cshtml/views/home/_layout.cshtml /Views/shared/_layout.en.cshtml/views/shared/_layout.cshtml /pages/shared/_layout.en.cshtml/pages/shared/_layout.cshtml
i在_ViewStart中设置BreaKepoint,并且不活动:
为什么_viewStart.cshtml不起作用,并且不更改布局?
I change Layout by default in _ViewStart.cshtml
@{
Layout = "_Layout-empty";
}
But it is layout does not work. _Layout is working.
Then I delete _Layout and get error:
InvalidOperationException: The layout view '_Layout' could not be
located. The following locations were searched:
/Views/Home/_Layout.en.cshtml /Views/Home/_Layout.cshtml
/Views/Shared/_Layout.en.cshtml /Views/Shared/_Layout.cshtml
/Pages/Shared/_Layout.en.cshtml /Pages/Shared/_Layout.cshtml
I set breakepoint in _ViewStart and it does not active:
Why does not _ViewStart.cshtml work and does not change layout?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
错误意味着它正在寻找_layout.cshtml..cshtml..您可以在_viewstart.cshtml.lso中设置布局gloabaly。在_viewstart.cshtml中进行设置之前。
因此,您需要确保在浏览器中显示的视图不包含以下代码:
The error means it is looking for _Layout.cshtml.And you can set layout gloabaly in _ViewStart.cshtml.Also,you can set it in the view.And the setting in the view will be prior to the setting in _ViewStart.cshtml.
So you need to make sure the view you displayed in browser doesn't contain the following code: