What is ViewBag.Title in Razor?

From the ASP.NET site:

ViewBag is a dynamic object, which means you can put whatever you want
in to it; the ViewBag object has no defined properties until you put
something inside it.

The ViewBag.Title property is simply a string object. In this case it’s being used in the view to actually define the Title property. If you were to look in your _Layout.cshtml file you would likely see something like:

<title>@ViewBag.Title</title>

Remember when the property was defined in the view? When the page is finally rendered, that property ends up in the HTML markup looking like:

<title>Store</title>

Which sets the browser title.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)