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!

enter image description here

/// 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.

0


source to share


2 answers


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.

0


source


It seems to me that your UI project is missing the MVC and Razor assembly references.

Check links for

System.Web.MVC



System.Web.Razor

System.Web.Webpages

System.Web.Webpages.Razor

+1


source







All Articles