Showing posts with label ViewBag. Show all posts
Showing posts with label ViewBag. Show all posts

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"