I saw the ViewBag in MVC 3. How’s that different than ViewData in MVC 2?
I saw the ViewBag in MVC 3. How’s that different than ViewData in MVC
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It uses the C# 4.0 dynamic feature. It achieves the same goal as viewdata and should be avoided in favor of using strongly typed view models (the same way as viewdata should be avoided).
So basically it replaces magic strings:
with magic properties:
for which you have no compile time safety.
I continue to blame Microsoft for ever introducing this concept in MVC.
The name of the properties are case sensitive.