Visual Studio 2015 Broken Razor Intellisense

Visual Studio 2015 Broken Razor Intellisense

I solved this problem by resetting the user data

devenv.exe /resetuserdata

and remove the ".vs" folder in my project.


WARNING: this will reset all your user settings. Essentially, it is like resetting to factory defaults. You will lose any custom keyboard shortcuts, extensions you've installed etc.

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>

VS2015 - IntelliSense not working in razor views in a class library

A reply in the article Stephen Muecke commented with got me started in the right direction. The solution is a mix of probably my confusion of which config needs to be where, and what feels like a workaround to something...

  1. Set the [Output Path] of your class library project to [bin/]. Mohammad Chehab mentions this in his (currently offline?) blog post which was referenced in this article: http://thetoeb.de/2014/01/05/enabling-mvc5-intellisense-in-a-classlibrary-project/

  2. In your [ClassLibrary/Views] folder you should have a Web.config which includes the correct razor versions and namespaces. I just copied the contents of the Web.config from our working Web application project and added/changed some namespaces. Example below.

  3. In your [ClassLibrary] root folder you should change the App.config so that it also contains the system.web section with the compilation setting. Example below.

After changing these to a clean, close the solution, delete the bin folders, open the solution and for me it finally all worked again.
I do have a sporadic issue with System.Web.Mvc.xml being locked, perhaps a side effect of the output path change that MS did not foresee or something... Perhaps nothing to worry about.

Hope this helps some poor googling soul some day.

Project/Views/Web.config

<?xml version="1.0"?>

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

<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.3.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.Optimization"/>
<add namespace="System.Web.Routing" />
</namespaces>
</pages>
</system.web.webPages.razor>

<appSettings>
<add key="webpages:Enabled" value="false" />
</appSettings>

<system.webServer>
<handlers>
<remove name="BlockViewHandler"/>
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
</handlers>
</system.webServer>

<system.web>
<compilation>
<assemblies>
<add assembly="System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
</compilation>
</system.web>
</configuration>

Project/App.config

<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=301880
-->
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.6" />
</system.web>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Security.OAuth" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Security.Cookies" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" />
<bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

Visual Studio 2015 razor editor not working

After some search i found the solution. the issue was with the Microsoft web development tool it was not installed correctly( I still don't know why :) ) in my system when i install visual studio 2015. When i tried to modify the visual studio it didn't let me install web development tool (Update button was disabled). So i tried an alternative solution install asp.net core https://www.microsoft.com/net/core#windows because i know it comes with web development tool so i just tried installing and it fixed my issue.

VS 2015 Razor Autocomplete/Intellisense dropdown hides immediately after dropdown

I haven't found the root cause, but in all cases, CTRL+SPACE works. This isn't the best, but light years better than nothing at all.

(this shortcut is not one I've used in the past, so this is likely standard behavior, but...) If you're at the dot Model. and autocomplete list disappears, CTRL+SPACE consistently brings it back up, and when it does come back, it stays! If there's only one possible autocomplete member, it'll auto-fill the member for you upon CTRL+SPACE

Visual Studio 2015 Intellisense not working

Probably the problem is with ReSharper, I'm running VS2013 and VS2015 on the same machine without any issues.

I would try:
In Visual Studio 2015, go to 'Tools | Options | Text Editor | C# | General both "Auto list members" and "Parameter information" should be checked.

If that doesn't work I would try to disable ReSharper in VS2013 and try to get the normal intellisense working. Same procedure as above if ReSharper fails to restore the settings.

Visual Studio 2015 not syntax highlighting razor nor Intellisense

I've found in this answer another way to fix it without the devenv.exe /ResetUserData

Just delete the contents of this directory with Visual Studio closed:
%LocalAppData%\Microsoft\VisualStudio\<visual_studio_version_number>\ComponentModelCache

To find the version number of the Visual Studio edition your are running please refer this list. Note that only the major number is important, the minor version can and will probably differ. In my case I had Visual Studio 2017 Enterprise installed so I looked for 15.xx and found 15.0_9a1c4a06 inside the AppData folder.



Related Topics



Leave a reply



Submit