Data transferring from controller to views and action to action | Lecture 09
1 min read
There are different ways through which you can transfer data from a controller to its view out which three are most common and remain in frequently use of programmers, ViewData, ViewBag and TempData.
ViewData the oldest one and still the fastest one, It was first time introduced with MVC 1.0 Version and still supported in all the latest versions.
ViewBag is new one but similar to the ViewData in functionality but slower than ViewData and it was first introduced in .NET Framework 4.0 so the version before 4.0 do not provide the support of the viewbag, Although MVC 3.0 provide its support.
Viewbag is actually the collection of view datas...it simplify the syntax of view data.
TempData also works for moving data from Controller to its view same like ViewBag and ViewData but it keeps the data for temp time and its best to move data internally from one controller to the other controller.