다음은 ASP.NET Core 1.0의 기본 템플릿에서 제공하는 _Layout 페이지의 전체 소스다. 책에서는 _Layout.cshtml 파일의 내용을 몇 개 수정해 독자의 환경과 조금 다를 수 있으니 참고만 하기 바란다. 전체적인 HTML5 레이아웃에 RenderBody()와 RenderSection()으로 레이아웃을 상속 받아서 사용하는 각각의 페이지에서 실제 내용이 포함될 영역을 지정하고 있다.
▼ Views/Shared/_Layout.cshtml 페이지 소스 전체
<!DOCTYPE html> <html> <head> <meta charset=“utf-8” /> <meta name=“viewport” content=“width=device-width, initial-scale=1.0” /> <title>@ViewData[“Title”] - 닷넷노트</title> <environment names=“Development”> <link rel=“stylesheet” href=“~/lib/bootstrap/dist/css/bootstrap.css” /> <link rel=“stylesheet” href=“~/css/site.css” /> </environment> <environment names=“Staging,Production”> <link rel=“stylesheet” href= “https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.6/css/bootstrap.min.css" asp-fallback-href=“~/lib/bootstrap/dist/css/bootstrap.min.css” asp-fallback-test-class=“sr-only” asp-fallback-test-property=“position” asp-fallback-test-value=“absolute” /> <link rel=“stylesheet” href=“~/css/site.min.css” asp-append-version=“true” /> </environment> <environment names=“Development”> <script src=“~/lib/jquery/dist/jquery.js”></script> <script src=“~/lib/bootstrap/dist/js/bootstrap.js”></script> <script src=“~/js/site.js” asp-append-version=“true”></script> </environment> <environment names=“Staging,Production”> <script src=“https://ajax.aspnetcdn.com/ajax/jquery/jquery-2.2.0.min.js" asp-fallback-src=“~/lib/jquery/dist/jquery.min.js” asp-fallback-test=“window.jQuery”> </script> <script src= “https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.6/bootstrap.min.js" asp-fallback-src=“~/lib/bootstrap/dist/js/bootstrap.min.js” asp-fallback-test= “window.jQuery && window.jQuery.fn && window.jQuery.fn.modal”> </script> <script src=“~/js/site.min.js” asp-append-version=“true”></script> </environment> </head> <body> <div class=“navbar navbar-inverse navbar-fixed-top”> <div class=“container”> <div class=“navbar-header”> <button type=“button” class=“navbar-toggle” data-toggle=“collapse” data-target=”.navbar-collapse”> <span class=“sr-only”>Toggle navigation</span> <span class=“icon-bar”></span> <span class=“icon-bar”></span> <span class=“icon-bar”></span> </button> <a asp-area=”” asp-controller=“Home” asp-action=“Index” class=“navbar-brand”>닷넷노트</a> </div> <div class=“navbar-collapse collapse”> <ul class=“nav navbar-nav”> <li><a asp-area=”” asp-controller=“Home” asp-action=“Index”>Home</a></li> <li><a asp-area=”” asp-controller=“Home” asp-action=“About”>정보</a></li> <li><a asp-area=”” asp-controller=“Home” asp-action=“Contact”>연락처</a></li> </ul> </div> </div> </div> <div class=“container body-content”> @RenderBody() <hr /> <footer> <p>© @DateTime.Now.Year - DotNetNote</p> </footer> </div> @RenderSection(“scripts”, required: false) </body> </html>