c# - The name 'ViewBag' does not exist in the current context - Visual Studio 2015 -


i'm starting develop in asp.net again , ran small error within visual studio. .cshtml files show errors when using few razor functions. example "the name 'viewbag' not exist in current context". here picture:

screenshot of problem in visual studio 2015

i using demo project. can find project here: https://github.com/wintellect/angular-mvc-cookbook/tree/master/basicproject

i have looked through several other threads , suggest update web.config file(s). these 2 config files present , since it's pretty popular demo assume has required configuration in it. have of course looked through these config files , indeed include suggested solutions.

other details:

  • i have used clean & rebuild on solution changed nothing.
  • when create new mvc project work
  • my friend has same problem , both use vs 2015 , windows 10
  • i can still run application , work.

thanks in advance.

i had issue despite having correct configuration.

it turned out bad files in component cache, preventing razor views recognising viewbag, model, , htmlhelpers. deleting these files solved problem (good versions of these files created next time opened visual studio).

the files located here:

c:\users\your.name.here\appdata\local\microsoft\visualstudio\14.0\componentmodelcache 

delete 4 files:

  • microsoft.visualstudio.default.cache
  • microsoft.visualstudio.default.catalogs
  • microsoft.visualstudio.default.err
  • microsoft.visualstudio.default.external

i have subsequently seen same issue on several other developer machines , fix solves it.


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -