мастер-представление
файл Views/MyTemplate1.cshtml
<!DOCTYPE html>
<html>
<!-- заголовок страницы -->
<head>
<meta name="viewport" content="width=device-width" />
<title>@ViewBag.MyTitle</title>
</head>
<body>
<!-- мое меню -->
<center>
<a href=''>Главная</a>
<a href=''>Новости</a>
<a href=''>Поиск</a>
</center>
<!-- тут вставится содержимое обычного представления -->
@RenderBody()
<!-- тут вставится секция -->
@if (IsSectionDefined("myFooter1"))
{
@RenderSection("myFooter1")
}
else
{
<b>Нет footer</b>
}
</body>
</html>
Обычное представление
файл Views/Home/Index.cshtml
@{
Layout = "~/Views/MyTemplate1.cshtml";
}
<div style='text-align:center;'>
<br />
Привет!
<br />
Это моя первая страница.
<br />
<br />
</div>
@section myFooter1 {
<center>
<b>Copyright 2018</b>
</center>
}