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.
Markdown for AI
A clean, structured version of this page for AI assistants and LLMs.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
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.