filmov
tv
Pass Data from Controller to View using View Data in ASP.NET MVC 5 | Part 33
![preview_player](https://i.ytimg.com/vi/Gy9uvn1nV04/maxresdefault.jpg)
Показать описание
Pass Data from Controller to View using View Data in ASP.NET MVC 5:
Here you can learn how to pass data from controller to view using view data.
View Data:
• ViewData is similar to ViewBag, it transfers data from Controller to View.
• ViewData is of Dictionary type and ViewBag is of dynamic type.
• So, both store data in the same dictionary internally.
• ViewData is a dictionary, so it contains key-value pairs where each key must be a string.
• ViewData life only lasts during the current HTTP request.
ViewData values will be cleared if redirection occurs.
• ViewData value must be typecast to an appropriate type before using it.
Here you can learn how to pass data from controller to view using view data.
View Data:
• ViewData is similar to ViewBag, it transfers data from Controller to View.
• ViewData is of Dictionary type and ViewBag is of dynamic type.
• So, both store data in the same dictionary internally.
• ViewData is a dictionary, so it contains key-value pairs where each key must be a string.
• ViewData life only lasts during the current HTTP request.
ViewData values will be cleared if redirection occurs.
• ViewData value must be typecast to an appropriate type before using it.