【问题标题】:Other pages do not see the layout page其他页面看不到布局页面
【发布时间】:2021-01-01 02:36:20
【问题描述】:

我正在工作.netcore 项目。管理区域其他页面看不到布局页面。我知道它是如何工作的。我也做过很多网站上发生的事情,但是一直没有解决。viewstart的页面代码:

@{
    Layout = "_Layout";
}

Dosya düzeninin 照片:

【问题讨论】:

  • 能否提供完整路径Layout = "~/Views/Shared/_Layout.cshtml";
  • 写的时候,用户的_layout页面来了,我要给admin的layout页面
  • 如果布局页面取决于用户,我建议在该代码中使用 IF 语句。 @{ if (user.IsAdmin) Layout = "_LayoutAdmin"; else Layout = "_LayoutUser"; }

标签: html asp.net asp.net-mvc asp.net-core


【解决方案1】:

只需将Layout更改为以下url,即Admin区域中的layout.cshtml:

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

【讨论】:

    猜你喜欢
    • 2016-05-27
    • 1970-01-01
    • 2013-11-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-10-12
    • 1970-01-01
    相关资源
    最近更新 更多