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 5.2.2.0 (Runtime version v4.0.30319) 

Per Views –> web.config:

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

Project web.config:

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

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?

Thanks,

edit: formatting

by nufsven via /r/csharp

Leave a Reply