I recently installed ASP.NET MVC 3 via web platform installer. I don’t have the intellisense support for ViewBag in Razor view. Intellisense works fine with model in Razor view. I tried to rebuild solution, disable ReSharper… but I couldn’t get it to work.
Any help would be greatly appreciated.
The
ViewBagproperty is typed asdynamic, which means that there is no IntelliSense.ViewBagis an alias/alternative syntax for accessing theViewDatadictionary. The two following lines of code are equivalent:ViewBagoffers a slightly terser syntax thanViewData. Also notice that accessingViewDatausing string keys also provides no IntelliSense, so you don’t really lose any functionality.One last note is that
ViewBagandViewDatause the same backing storage, so that setting a property using one method makes it available using the other method: