IntelliSense files in Razor (.cshtml) stopped working

Intellisense does not work in razor files:

enter image description here

In my web.conifg file (in the Views folder), it seems to be correct:

<?xml version="1.0" encoding="utf-8"?> <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.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="MvcSiteMapProvider.Web.Html" /> <add namespace="MvcSiteMapProvider.Web.Html.Models" /> <add namespace="DevTrends.MvcDonutCaching" /> </namespaces> </pages> </system.web.webPages.razor> <appSettings> <add key="webpages:Enabled" value="false" /> </appSettings> <system.webServer> <validation validateIntegratedModeConfiguration="false" /> <handlers> <remove name="BlockViewHandler" /> <add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" /> </handlers> </system.webServer> </configuration> 
+63
razor asp.net-mvc-5
Jan 23 '14 at 13:39
source share
18 answers

Here's what worked for me after IntelliSense unexpectedly started to fail and stopped correctly painting C # code between HTML tags in my views:




Just delete the contents of the folder in %LOCALAPPDATA%\Microsoft\VisualStudio\14.0\ComponentModelCache

If you are using VS 2019, the version folder is called 16.0_<hash> .




enter image description here

As an additional step, you can optionally run the DevEnv.exe /setup command on the developer’s command line for VS (as an administrator) if the above step does not solve the problem.

+92
Nov 09 '15 at 15:23
source share

When intellisense stops working in the razor file, there is a good chance that the problem can be fixed in three stages:

  • Close Visual Studio
  • Delete solution user settings file ( <solution-name>.suo )
  • Reopen the solution in Visual Studio.

Other solutions for intellisense options can be found here .

+16
Mar 23 '15 at 18:47
source share

One of the reasons for this may be that if your applications for version mvc4 are installed on version 3, you can simply change it to version 2 in the settings of the web.config application.

  <appSettings> <add key="webpages:Version" value="2.0.0.0" /> 
+15
Nov 18 '14 at 11:37
source share

I experienced this in Visual Studio 2013 after upgrading the project to MVC 5.2.3. The thing that worked for me was to replace web.config in the Views folder with the following: the NuGet package left this web.config with many MVC 4.0 links.

 <?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.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.Optimization"/> <add namespace="System.Web.Routing" /> <add namespace="InvestureApps" /> </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> </configuration> 
+13
Sep 25 '15 at 14:24
source share

In my case, the problem is "Xamarin" (tools for developing mobile applications). After removing Xamarin, the Intellisense razor works fine.

http: //forums.xamarin.com/discussion/24892 ...

+4
Dec 17 '14 at 10:45
source share

I had the same problem. Although I use VS 2012, there is a download that applies to both VS 2013 and VS 2012. I tried quite a few fixes (related to web.config, uninstalling / reinstalling MVC via NuGet, etc.), but only that that worked for me installed this (again, for me, for VS 2012)

VS 2013 with ASP.NET and web tools 2013.1 http://www.asp.net/downloads

+3
Jan 28 '14 at 23:31
source share

My project was upgraded from VS2012 to VS2013, and this solved the problem for me:

Change "webpages: Version" in the Web.config file from "1.0.0.0" to "2.0.0.0"

 <appSettings> <add key="webpages:Version" value="2.0.0.0" /> 
+3
May 12 '15 at 15:56
source share

I had this problem with Visual Studio 2017 - I went into the directory where the solution is located and deleted the .s vs folder (this is a hidden folder) and this fixed my problem.

+2
Oct 08 '18 at 21:30
source share

It seems that there are many reasons causing this problem.

In my case, I copied some code / files from another project, after which Intellisense does not work, because I have a different namespace in the copied files, so Intellisense does not work. the correct namespace makes it work again.

+1
Sep 13 '18 at 3:26
source share

Keep track of whether you have areas in your web application, there is another Web.config file in the Areas / Views folder, and in my case this configuration file was the culprit.

Also, you may have to restart Visual Studio after making changes to Web.config, rebuilding the solution does not seem to pick up the changes, at least this is not for me.

0
Oct 03 '15 at 10:27
source share

ASP.NET installation and web tools 2013.1 for Visual Studio 2012 worked for me:

You may need to restart VS for this.

0
Nov 25 '15 at
source share

I had a very similar problem: the existing application did not provide intellesense for Razor views, but I could create a completely new application and it worked. I was able to solve the problem using Scaffolding to create a new controller and views for the object. Intellesense worked for a new facility, and it worked again for existing ones!

0
Jun 21 '16 at 11:54 on
source share

After many searches and tests, I found that without installing 2013 or any updated version, you can still solve this problem with the coloring for 2012. Installing "ASP.NET and Web Tools 2013.1 for Visual Studio 2012" solved this for me. Close VS 2012 and restart it after installation.

Link to Dowload, https://www.microsoft.com/en-us/download/details.aspx?id=41532

It worked for me. Hope this works for all of you.

0
Sep 06 '17 at 6:16
source share

I had a similar situation, and I realized that the razor look was not included in my project. As soon as I included it in the project (right-click the view file and select "Include in Project"), Intellisense appeared.

0
Nov 16 '17 at 21:14
source share

In my case, this solved my problem, I just changed the version value from 3 to 2. and this works for me.

0
Jan 07 '18 at 9:06
source share

I just needed to right-click β€œAdd to Project” for my new view to select Intellisense.

0
May 21 '18 at 17:33
source share

In my case, installing a newer version (nightly build) of Resharper (2018.3 EAP 3) helped.

0
Oct 22 '18 at 14:01
source share

In my case, none of the above helped, here is what I did to solve my problem:

Download the project using VS and leave it, and then open your-project-name.csproj with Notepad ++ or any other text editor that you like and made some changes, such as removing the content tag (don't worry, it will be If you enable it again in VS Solution Explorer), as soon as you save your changes, the Visual Studio IDE will detect your changes and ask you to restart the entire project, click "Yes" and my IntelliSense code will return.

I use: Microsoft Visual Studio Professional 2019 Preview Version 16.3.0 Preview 2.0

Hope this helps.

0
Aug 19 '19 at 23:42
source share



All Articles