Wednesday, January 9, 2013

The name 'ViewData' does not exist in the current context

In an application where I played the class diagram in visual studio by adding
controller class, repository class, and service class, I encountered an error
"The name 'ViewData' does not exist in the current context" in my HomeController.

This is weird since the controller references System.Web.Mvc. The solution is:

1. Copy the source code in the HomeController and transfer it in a textfile for backup.
2. Delete the original HomeController.
3. Add another HomeController class
4. paste the backup code from the textfile.

I guess this is a bug when using class diagrams in Visual Studio 2010.



Post a Comment