What is the difference between viewdata and viewbag?



What is the difference between viewdata and viewbag?..

Answer / Suleman Ahmad Salmani

ViewData and ViewBag in MVC are used to pass data to the view from the controller. However, there is a subtle difference between them. ViewData is strongly typed (i.e., you have to specify the type of the data), while ViewBag is dynamically typed (i.e., you don't need to specify the type, and it automatically detects the data type based on the name).

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More MVC Model View Controller Interview Questions

What is non action attribute in mvc?

1 Answers  


What is a glimpse?

1 Answers  


Explain the need of display mode in mvc?

1 Answers  


How can maintain session in mvc?

1 Answers  


Why we need "Areas" in MVC?

1 Answers   Cognizant,


What is mvc in simple words?

1 Answers  


Is mvc only for web?

1 Answers  


What is the difference between asynchronous and synchronous actions? When would you use asynchronous actions?

1 Answers  


Mention how can maintain session in mvc?

1 Answers  


Is there viewstate in mvc?

1 Answers  


Is angular js mvc?

1 Answers  


What is mvc core?

1 Answers  


Categories