Visual studio throws me these errors that are seen in the image, even when I have the code well done and also when I run the page everything is fine.
Recently I had the same problem what I did last time was to delete the contents of the folder
C:\Users\tuUsuario\AppData\Local\Microsoft\VisualStudio.0\ComponentModelCache
Those errors happened to me when I made a project migration ASP .NET MVC 4
to ASP .NET MVC 5
via Nuget
.
This is optional because the above can work safely
To correct the error, I had to manually change the version of System.Web.WebPages.Razor
from 2.0.0.0
to 3.0.0.0
in the web.config of the views:
<configSections>
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
</sectionGroup>
</configSections>
a
<configSections>
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
</sectionGroup>
</configSections>
After that, the web application runs fine, but complained that Visual Studio @Model
does not exist in the current context. This time I had to change all the instances of System.Web.Mvc, Version = 4.0.0.0
to System.Web.Mvc, Version = 5.2.3.0
, restart the Visual Studio, and rebuild the project.
Reference: