What is ViewBag.Title in Razor?
问题 What is ViewBag.Title in ASP.NET MVC 4? I have that View file: @model IEnumerable<MvcMusicStore.Models.Genre> @{ ViewBag.Title = "Store"; } <h2>Index</h2> and I do not know what changing ViewBag.Title may accomplish. 回答1: 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