The name does not exist in the current context (razor)
I got a few problems with the razor and yet it stresses me out again.
I opened a project that is dotted with red Squiggles inside a razor. This is a very difficult task since I am a Webforms developer switching to MVC.
I am running visual studio 2015.
At first I thought it might be a version issue, but it all seems good. WebConfig seems to be up to date. I am at a loss and need guidance. Any help is greatly appreciated!
/// edits
Web.config views.
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<add namespace="System.Web.Optimization" />
Looks like I'm missing the razor namespace. I cannot add this to links.
source to share
Find the section <system.web.webPages.razor>
in your web.config. This config file can be found under Views -> web.config. If you have version 4.0.0.0 for System.Web.Mvc.MvcWebRazorHostFactory
, then change it to Version = 5.0.0.0 . It should look like this:
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
Note. Make sure you call all views in Visual Studio and reopen them.
source to share