Error 'The name ViewBag does not exist in current context.'

Jan 14, 2011 at 8:44 PM

I've got the completed solution.  I attached my database.  I'm getting the following build error..

The name 'ViewBag' does not exist in the current context C:\MvcMusicStore2.0Completed\MvcMusicStore\Controllers\AccountController.cs 150 13 MvcMusicStore

Any Ideas?

Thanks

Jan 14, 2011 at 10:32 PM

I got it fixed.  In the controler classes the 'ViewBag' needed to be changed to 'ViewModel'.  In the Views, the 'ViewBag' needed to be changed to 'View'.  That fixed it, now I'm up and running!!

Coordinator
Jan 14, 2011 at 11:07 PM
Edited Jan 14, 2011 at 11:12 PM

Sounds like you're running a pre-release version of ASP.NET MVC 3. The RTM version of ASP.NET MVC 3 uses ViewBag in codebehind and view code. I recommend you update to the RTM: http://www.microsoft.com/web/gallery/install.aspx?appid=MVC3