What is the differnce between ViewBag and ViewData in asp.net MVC 3?
Which is the best to use with Razor view engine?
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jiteendra SampathiraoPosted Jul 1, 2011, 8:32 AM
refer this link:
Link(viewbag and view data)
you will definitely get an idea........
Dorababu MekaPosted Jul 1, 2011, 8:02 AM
http://weblogs.asp.net/hajan/archive/2010/12/11/viewbag-dynamic-in-asp-net-mvc-3-rc-2.aspx
Viewbag 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: