Remark :
Layout
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; namespace WebApplication8.Controllers { public class LayoutController : Controller { public IActionResult Page1() { return View(); } public IActionResult Page2() { return View(); } public IActionResult Page3() { return View(); } } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width" /> <title>@ViewBag.Title</title> </head> <body> <div style="width:100%;background:#dfdfdf"> <ul> <li>@Html.ActionLink("Page1", "page1")</li> <li>@Html.ActionLink("Page2", "page2")</li> <li>@Html.ActionLink("Page3", "page3")</li> </ul> </div> <div style="width:100%;background:#ffffff"> @RenderBody() </div> </body> </html> |
1 2 3 4 5 6 7 8 |
@{ ViewData["Title"] = "Page1"; Layout = "~/Views/Layout/MyLayout.cshtml"; } <h1>Page1</h1> |