MVC Razor view Intellisense broken in VS 2013/2015/2017

I considered editing @ChrisMoschini’s post, but thought it was different enough. My issue was that I started a new MVC5 application, and blindly copied over too many web.config settings from an old MVC3 project I wanted to use as a template/starting point. Doing this caused me to have some invalid versions referenced in my web.config.

To fix, I created another new MVC5 project and made sure the following config values in my bad project matched the vanilla, unmodified MVC5 app. Again, do not blindly copy these version numbers. Just make sure they match a vanilla MVC app of the version that you’re trying to get to work

in root web.config:

<appSettings>
    ...
    <add key="webpages:Version" value="3.0.0.0"/> 
    ...
</appSettings>
<system.web>
    ...
    <compilation debug="true" targetFramework="4.5.1"/>
    <httpRuntime targetFramework="4.5.1"/>
    ...
</system.web>

in the Views\Web.config:

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


<system.web.webPages.razor>
  ...
  <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
  ...
</system.web.webPages.razor>

Leave a Comment