Layout trong ASP.NET MVC là gì?
Layout trong ASP.NET MVC là gì?
Layout (_Layout.cshtml) là template giao diện dùng chung (header, menu, footer, CSS/ JS) cho nhiều View — tương đương Master Page của Web Forms.
@* Views/Shared/_Layout.cshtml *@
<!DOCTYPE html>
<html><head><title>@ViewBag.Title - KFT</title>@await RenderSectionAsync("Styles", required: false)</head>
<body>
<header>...menu...</header>
<main>@RenderBody()</main> @* nơi View con chèn vào *@
<footer>© @DateTime.Now.Year</footer>
@await RenderSectionAsync("Scripts", required: false)
</body></html>
@* View con *@
Đăng nhập để tham gia thảo luận cùng mọi người.
Chưa có bình luận nào
Hãy là người đầu tiên chia sẻ suy nghĩ của bạn.