What is the ViewBag? - ASP.NET MVC Demystified

ASP.NET MVC provides us with three ways to pass data from Controllers to Views. We've already discussed using TempData to create a FlashMessage partial. Now, let's discuss the second method available to us: ViewBag. What's in the Bag? ViewBag, according to MSDN, "enables you to dynamically share values from the controller to the view". The key word there is "dynamically"; ViewBag is of type dynamic. Essentially, they are a type where the actual type (e.... Read more >