Home > DeveloperSection > Forums > What's the difference between ViewData and ViewBag?
Pawan Shukla

Total Post:38

Posted on    March-04-2015 6:33 AM

 .NET Mvc  Viewbag  Viewdata 

 1 Reply(s)
 849  View(s)
Rate this:

I saw the ViewBag in MVC 3. How's that different than ViewData in MVC 2?

Kamlakar Singh
Kamlakar Singh

Total Post:194

Posted on    March-04-2015 6:37 AM

ViewData & ViewBag objects

·         ViewData

·         ViewData is a dictionary object that you put data into, which then becomes available to the view. ViewData is a derivative of the ViewDataDictionary class, so you can access by the familiar "key/value" syntax.

·         ViewBag

·         The ViewBag object is a wrapper around the ViewData object that allows you to create dynamic properties for the ViewBag.

Don't want to miss updates? Please click the below button!

Follow MindStick