2

I promise I am complete newbie to MVC Core (I have only 1 week practice) I know how to add a master page to a Dot net framework but not to MVC Core. Can anyone help me? Thanks

George K
  • 468
  • 2
  • 13
user1238784
  • 1,682
  • 3
  • 18
  • 31
  • 3
    It's called Layout page in MVC. Search this term and you'll find some more information. – Yan May 21 '18 at 10:02
  • 2
    this link will help you: https://stackoverflow.com/questions/5161380/how-do-i-specify-different-layouts-in-the-asp-net-mvc-3-razor-viewstart-file – Hasan Gholamali May 21 '18 at 10:09

2 Answers2

6

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";
}
Mr. Roshan
  • 1,684
  • 7
  • 30
0

You should add _Layout.cshtml to /Views/Shared folder

Ramil Mammadov
  • 306
  • 4
  • 10