在 MVC 核心应用程序中创建母版页

Create a Master Page in MVC Core application

我保证我是 MVC Core 的新手(我只有 1 周的练习时间)我知道如何将母版页添加到 Dot net 框架而不是 MVC Core。谁能帮我?谢谢

Layout Page Structure (Layout1.cshtml)

<!DOCTYPE html>  
<html>  
<head>  
    <meta name="viewport" content="width=device-width" />  
    <title>@ViewBag.Title</title>  
@RenderSection("head", false)  
</head>  
<body>  

     @Html.ActionLink("Home", "Index", "My") |   
     @Html.ActionLink("AboutUs", "AboutUs", "My") |   
     @Html.ActionLink("ContactUS", "ContactUS", "My") |   
     @Html.ActionLink("Facebook", "Facebook", "My") |   
     @Html.ActionLink("Twitter", "Twitter", "My")  

    <br />  
        @RenderBody()  
    <br />  

    Hello Nitin Pandit…………This is the demo of Layout pages.  

</body>  
</html> 

Set the Layout Page of your view when creating of your action method view

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

您应该将 _Layout.cshtml 添加到 /Views/Shared 文件夹