ViewBags and project configuration

I am getting the error "The name 'ViewBag' does not exist in the current context" in my view (.cshtml) files.

Based on what I've read it looks like it has to do with an incorrect configuration resulting from upgrading MVC versions (from 4 to 5).

References --> System.Web.Mvc properties: Version (Runtime version v4.0.30319) 

Per Views –> web.config:

configuration --> configSections --> sectionGroup "system.web.webPages.razor" Version = --> section name="host" & "pages" Version also = system.web.webPages.razor --> host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35" system.web --> pages pageParseFileType / pageBaseType / userControlBaseType Version = system.web --> controls --> add assembly="System.Web.Mvc, Version= 

Project web.config:

appSettings --> add key="webpages:Version" value="" 

Is there any where online I can go to confirm that the version #'s are correct?

Also, could there be another reason why I'm getting this error?


edit: formatting

by nufsven via /r/csharp

Leave a Reply