Saturday, February 1, 2014

ViewBag vs ViewData in ASP.NET MVC

Bottom line is that they are essentially the same, ViewBag is just a dynamic wrapper around ViewData. ViewData is actually a dictionary used to pass data from controllers to views. The following example will make this clear,

ViewBag.Name = "Padmika"

is equal to,

ViewData["Name"] = "Padmika"

0 comments:

Post a Comment