I was going through the list of NuGet Packages and I was updating everything things like bootstrap, jQuery, etc. but while I was doing that, I unthinkingly updated M
I have spent days digging around on this problem and now waiting for my hair to grow back. But alas persistence.
Visual Studio 2013 Update 4, targetFramework 4.5.1 System.Web.Mvc 5.2.2.0
Ensure web.config files (in the root directory and view directory(ies)) are utilizing the proper versions for mvc and razor as explained above. However if the razor intellisense problem still exists, begin by checking your installed packages.
Easiest way is to create a new solution, and install / update packages one by one to identify the problematic packages.
In my case updating the solution's Webgrease / Modernizr / ANTLRv3 packages via nuget to version 1.6.0 / 2.8.3 / 3.5.0.2 caused all the problems and self-induced male pattern baldness.
After days of searching, I finally found this page: MVC Razor view Intellisense broken in VS 2013/2015/2017
In my Views > Web.Config file I found this code:
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<namespaces>
<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" />
<add namespace="System.Web.Helpers"/>
<add namespace="IcapOrg" />
</namespaces>
</pages>
</system.web.webPages.razor>
Which, as you can see, has the wrong version of MVC on it. I had previously only checking the <sectionGroup>
tags for the proper version of RAZOR but I neglected the fact that MVC also needs the proper version. Switching the version to:
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
Solved my problem. This reminds me to always look over my code VERY carefully.
NOTE: As you can see in the question, the version says 5.0.0, and this one says 4.0.0. Different Web.Config files in my different view folders all had different versions written down. Extremely weird.