All posts tagged '.net'

.NET Musings

Wandering thoughts of a developer, architect, speaker, and trainer


CS0103: The name 'ViewBag' does not exist in the current context

Technorati Tags: ,

I hit this error today while working with an MVC3 application.  It appeared out of the blue – but don’t they always?  Fortunately, I make a habit of committing my work into SVN every time my tests pass, so I could have just reverted back to my last Revision, but I wanted to know what I did to cause this.

Much to my demise, the optimistic fixes didn’t work:

  • Restart the debugger several times, because surely that will fix it :-)
  • Close Visual Studio and reopen it.

Just kidding.  But we do tend to try those don’t we?

Back on topic, I looked at the changes between my current work space and the last working revision.  Turns out somehow the web.config in the Views directory was deleted.  Once I restored the file from SVN, all worked wonders again.

Wonderfully descriptive error message, isn’t it?

Happy Coding!

Managed Windows Shared Hosting by OrcsWeb