Interview Questions Answers.ORG
Interviewer And Interviewee Guide
Interviews
Quizzes
Home
Quizzes
Interviews Coding/Programming Interviews:Active Template Library (ATL)ActiveXApplication DeveloperArtificial intelligenceAssemblyAssociate Software EngineerAWKAWTC ProgrammingC++ ProgrammingCGI PerlCGI ProgrammingCMMICobolCritical ReasoningData Structures TreesDCOM COMDelphiDTDE4XExtensible Stylesheet Language (XSL)FortranFull-Stack DeveloperHaskellHTML DOMILUIPhone DeveloperJasper Reports DeveloperJava DeveloperLisp ProgrammingLotus NotesMicrosoft Foundation Class (MFC)Mobile DeveloperMVC DeveloperNode.jsOOPPascalPerl ProgrammingPHPPHP DeveloperProgrammingProgramming AlgorithmsProgramming ConceptsPythonRubyRuby on RailsRuby on Rails DeveloperSenior Front End DeveloperSenior Software DeveloperSignature ProgramSOASocket ProgrammingSoftware Development EngineerSoftware engineeringSr. PHP ProgrammerStack And QueueSTLSwift DeveloperTCL (Tool Command Language)Team Leader Android DeveloperUMLUnity 2D Games DeveloperUnity 3D DeveloperUnity DeveloperVBA (Visual Basic for Applications)Visual Basic (VB)Visual C++Web DevelopmentWin32APIWindows ProgramingWordPress DevelopmentWSDLXFormsXHTMLXLinkXMLXPathXQueryXSL-FOXSLT
Copyright © 2018. All Rights Reserved
MVC Developer Interview Question:
Explain me what is the difference between Temp data, View, and View Bag?
Submitted by: MuhammadIn ASP.NET MVC there are three ways to pass/store data between the controllers and views.
ViewData
☛ ViewData is used to pass data from controller to view.
☛ It is derived from ViewDataDictionary class.
☛ It is available for the current request only.
☛ Requires typecasting for complex data type and checks for null values to avoid error.
☛ If redirection occurs, then its value becomes null.
ViewBag
☛ ViewBag is also used to pass data from the controller to the respective view.
☛ ViewBag is a dynamic property that takes advantage of the new dynamic features in C# 4.0
☛ It is also available for the current request only.
☛ If redirection occurs, then its value becomes null.
☛ Doesn't require typecasting for complex data type.
TempData
☛ TempData is derived from TempDataDictionary class
☛ TempData is used to pass data from the current request to the next request
☛ It keeps the information for the time of an HTTP Request. This means only 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
☛ It requires typecasting for complex data type and checks for null values to avoid error. Generally, it is used to store only one time messages like the error messages and validation messages
Submitted by: Muhammad
ViewData
☛ ViewData is used to pass data from controller to view.
☛ It is derived from ViewDataDictionary class.
☛ It is available for the current request only.
☛ Requires typecasting for complex data type and checks for null values to avoid error.
☛ If redirection occurs, then its value becomes null.
ViewBag
☛ ViewBag is also used to pass data from the controller to the respective view.
☛ ViewBag is a dynamic property that takes advantage of the new dynamic features in C# 4.0
☛ It is also available for the current request only.
☛ If redirection occurs, then its value becomes null.
☛ Doesn't require typecasting for complex data type.
TempData
☛ TempData is derived from TempDataDictionary class
☛ TempData is used to pass data from the current request to the next request
☛ It keeps the information for the time of an HTTP Request. This means only 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
☛ It requires typecasting for complex data type and checks for null values to avoid error. Generally, it is used to store only one time messages like the error messages and validation messages
Submitted by: Muhammad
Copyright 2007-2024 by Interview Questions Answers .ORG All Rights Reserved.
https://InterviewQuestionsAnswers.ORG.
https://InterviewQuestionsAnswers.ORG.