Hi Guest

HomePage

1 1

To improves our performance please Like Share Subscribe(Will boost us)

Difference between TempData, viewData and ViewBag in MVC
Question Posted on 08 May 2020

Home >> DotNet >> MVC >> Difference between TempData, viewData and ViewBag in MVC

Difference between TempData, viewData and ViewBag in MVC
Below are the main differences between Temp data, View and View Bag
TempData
(1)class name is TempDataDictionary where TempData is derived from.
(2)We generally used TempData to pass data from current request to next request.
(3)TempData will keep the information for the time of HTTP Request. This means from one page to another. It helps to maintain the data when we move from one controller to another controller or from one action to another action.
(4)It genaraly requires typecasting for complex data types and checks for null values to avoid error.
(5)We use TempData to store only one time messages like the error messages and validation messages

ViewData
(1)Class name ViewDataDictionary where ViewData is derived from.
(2)ViewData is used to pass data from controller to view.
(3)It is only available for current request only.
(4)It requires typecasting for complex data types and checks for null value to avoid error.
(5)IF any redirection done then its values becomes null.


ViewBag
(1)It is a dynamic property which takes advantages of new dynamic

features in c# 4.0
(2)And ViewBag is used to pass data from the controller to respective view.
(3)It is same as ViewData means available for current request only.
(4)It will not requires typecasting for complex data type.
(5)If there some redirection occurs then its values becomes null.
0
0



Most Visited Questions:-

Deep Learning Questions Answers
Below are the different Deep Leaning Questions and answer a More...

Continuous Integration Questions Answers
Below are the 20 odd questions for CI or Continuous Integra More...

Derived relationships in Association Rule Mining are represented in the form of __________.
Derived relationships in Association Rule Mining are repres More...

What is Gulpjs and some multiple choice questions on Gulp
Gulpjs is an open source whihc helps in building Javascript More...

Microservices Architecture Questions Answers
Below are the different questions on Microservices Architec More...




Other Important Questions
How to create Razor enable application in MVC3
Can you write down some syntax for Razor in MVC3
Basic diagram of MVC
Different MVC version with there features
Could not load type System.Web.Mvc.ViewPage in asp.net MVC2






Most Visited Questions
Top Searches:asp net questions vb net questions sql query uddl questions class javascript Questions sharepoint interview questions and concept silverlight questions and concept wcf questions beans general knowledge ajax questions
PHP | Biztalk | Testing | SAP | HR |
     
 
Privacy policy | Terms and Conditions | Blog


If the copyright of any questions or content or syntax belong to you email us we will remove that(info@crackyourinterview.com or crackyourinterview2018@gmail.com)
 

1
Home About Us GroupChat
 
Sitemap Feedback Contact us