e.g. 3.5 Retrieving a ViewBag Data Value

e.g. 3.6 Displaying Details of the Party
This commit is contained in:
Jason Zhu 2021-07-13 23:51:02 +10:00
parent 204f54b04a
commit 5945309b12
2 changed files with 3 additions and 1 deletions

View File

@ -10,6 +10,8 @@ namespace PartyInvites.Controllers
{ {
public ActionResult Index() public ActionResult Index()
{ {
int hour = DateTime.Now.Hour;
ViewBag.Greeting = hour < 12 ? "Good morning" : "Good afternoon";
return View(); return View();
} }

View File

@ -10,7 +10,7 @@
</head> </head>
<body> <body>
<div> <div>
Hello, world (from the view) @ViewBag.Greeting, world (from the view)
</div> </div>
</body> </body>
</html> </html>