ViewData: It is a Dictionary object derived from the ViewDataDictionary class. It requires type casting and null check for complex data types.
Controller:: ViewData[“Name”] = “Mindstick”;
View:: @ViewData[“Name”]
ViewBag and ViewData spans for a server call.
TempData: It is a dictionary derived from the TempDataDictionary class. It stores data in a short live session and spans for a HTTP request. It is used when moving from a controller to another or from an action method to another. It is for the current and subsequent request only. It requires type casting and null check for complex data types.
Join MindStick Community
You need to log in or register to vote on answers or questions.
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.
ViewBag: It is a dynamic property.
Controller:: ViewBag.Name = “Mindstick”;
View:: @ViewBag.Name
ViewData: It is a Dictionary object derived from the ViewDataDictionary class. It requires type casting and null check for complex data types.
Controller:: ViewData[“Name”] = “Mindstick”;
View:: @ViewData[“Name”]
ViewBag and ViewData spans for a server call.
TempData: It is a dictionary derived from the TempDataDictionary class. It stores data in a short live session and spans for a HTTP request. It is used when moving from a controller to another or from an action method to another. It is for the current and subsequent request only. It requires type casting and null check for complex data types.