Difference Between ViewData, ViewBag , TempData and Session

Posted By : Bipul Kumar Tiwari,


In ASP.NET MVC offers us three options - ViewData, ViewBag and TempData to pass data from controller to view and in next request. ViewData and ViewBag are almost similar and TempData performs additional responsibility

ViewData

View Data

ViewBag

View Bag

TempData

Session

Hidden Fields

Viewdata Viewbag Tempdata Session in MVC

Summary Table (View data, View bag , Temp data , Hidden field and session)


Maintains data between ViewData/ViewBag TempData Session Hidden fields
Controller to Controller NO YES YES NO
Controller to View YES NO YES NO
View to Controller NO NO YES YES


Related Articles

 

About the Author

author
Its me BIPUL who is logically minded creative at heart , a good communicator , a self taught full stack developer. I constantly focuses on my thinking , reading , collecting and creating my work in a order to enhance my skills.

I discover new dimensions for growing bussiness with a proven record in creating database and programming. I have a strong technical skills as well as strong interpersonal skills. Read more...
 

Browse By Category

Popular Articles