I know this error has been posted elsewhere, but the solutions provided don't work for me.
Background:
I get the following error:
Compiler Error Message: CS0103: The name 'ViewBag' does not exist in the current context
Source Error:
Line 1: @model MyModels.AModel
Line 2: @{
Line 3: ViewBag.Title = "Home Page";
Line 4: }
Line 5: <script type="text/javascript">
Argh. The server where I had deployed my app to had an old version of MVC3. I had ran the MVC3 installer prior to deploying my app, but apparently the installer does not remove previous beta or RC versions of MVC3. You must uninstall previous versions of MVC3 via add/remove programs prior to installing the newer version.
I was able to make this work in two ways:
Note: Restart IIS after any changes. (Recycling just the app pool would probably work, too.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With