I have a Windows 2003 R2 server. I have to run a .NET MVC3 website. I already installed all the Runtimes (1,2 and 4), i have installed all the MVCs frameworks (3 and 4) but this error doesn't go away.
I have the web.config that is supposed to be in the Views in place. I have followed all and each of the solutions to this problem in and out stackoverflow. I have also deployed in my bin folder all the dll by using Add Deployable Dependencies (right click on mvc project).
At this point i don't know what else to do. Ran out of ideas or solutions online.
I already uninstalled and reinstalled all the runtimes, frameworks, etc. In my local computer it runs just fine (windows 7) but when i deploy, i get following error.
Compiler Error Message: CS0103: The name 'ViewBag' does not exist in the current context
Source Error:
Line 1: @{
Line 2: ViewBag.Title = "Home Page";
Line 3: }
Line 4: <h2>@ViewBag.Message</h2>
Source File: d:\FamilyDermMVC\Views\Home\Index.cshtml Line: 2
I see this was posted awhile back, but thought I would add my experience with this issue anyway.
Upon creating a new MVC asp.net project I was getting this same error right off the bat. I simply clicked BUILD -> Clean Solution, then Build Solution and it fixed the problem for me. Still not quite sure why the error came about in the first place though as it errored out right after it first generated.
It seems there are many solutions and the success rate of each is mixed.
For me, changing the version number on this line of the Views/web.config file worked:
I changed 4.0.0.0 to 5.0.0.0, saved, closed the solution, re-opened, then voila! The annoying red squiggles were gones and the intellisense returned
installing ASP.NET MVC 5 support for Visual Studio 2012 from http://www.asp.net/mvc/mvc5 solves the issue for me.
I had the same type of problem (html helper code not being recognised).
I'm not sure how it started but i solved it by replacing the following:
with
in the views web.config file.
Found my solution here
Ok. I fixed it. I don't know exactly what fixed it but i guess this whole "9 miles" fixes it.
I removed (Remove Programs) all MVC extensions, tools and whatever you find there.
Then reinstalled, without removing, .net runtime. 2 and 4.
Then installed mvc3 and mvc4 back. I went to asp.net for the latest versions.
Then i did the same thing in my laptop.
NOTE: You will need Power Shell 2.0 in order to install MVC4 in Windows2003 server. You need to find the specific download for that server.
Once i did that, recycled app pool and restarted server.
BANG... page loaded.
I hope this helps other folks in the future.
Thank you for your answers thou.
PS: My feeling is that i didn't have the same version (or releases) of mvc3 (or mvc4) in my laptop and server respectively.
In my case i got this problem because i was trying to run an MVC 3 project into MVC 2 enabled platform.
then i installed MVC 3 on my system an problem gone away