如何在“Main Layout”中使用“UserPanel Layout”?

How to use " UserPanel Layout " in " Main Layout "?

我在 User_Panel 区域 :

创建了一个布局 ("_UserLayout.cshtml")

Click to see Image

就像我们在Admin_Panel中做的一样。 (边栏中的每个按钮都有一个 ActionResult)

但问题是我希望此布局位于网站的主布局内。也就是说,用户面板布局位于网站的内容部分:

Click to see Image

与所附照片完全一样。

如何在 Asp.Net Core 中实现?

我在用户面板区域的“_ViewStart.cshtml”中使用了主布局,但是每次在所有视图中重复用户布局(例如:边栏)是没有意义的.. .

很多网站的用户面板是这样的:

Click to see Image

最好的方法是什么?

非常感谢

您可以在任何布局页面中使用其他布局作为 Layout。例如:

站点主要布局(_BaseLayout.cshtml):

<html>
<head>...</head>
<body>
    @RenderBody()
</body>
</html>

管理布局(_AdminLayout.cshtml):

@{
    Layout = "_BaseLayout";
}
<!-- Put markups which are common to all admin pages -->
@RenderBody()

用户面板布局(_UserLayout.cshtml

@{
    Layout = "_BaseLayout";
}
<!-- Put markups which are common to all user pages pages (side panel etc) -->
@RenderBody()

您可以像这样构建布局。然后在所有用户页面中使用它,例如: 示例用户页面(UserAccount.cshtml)

@{
    Layout = "_UserLayout";
}
<!--  page markups -->