Intellisense does not work in razor files:
In my web.conifg file (in the Views folder) is apparently 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>
I had a similar situation, and then realized that the razor view wasn't included in my project. As soon as I included it in the project (right click the view file and select Include in Project), Intellisense showed up.
Installing ASP.NET and Web Tools 2013.1 for Visual Studio 2012 worked for me:
You might need to restart VS for this to work.
This is what worked for me after IntelliSense suddenly began to bug out and stopped colouring C# code correctly in between the HTML tags in my views:
Just delete the contents of the folder at
%LOCALAPPDATA%\Microsoft\VisualStudio\14.0\ComponentModelCache
If you're using VS 2019, the version folder is named
16.0_<hash>
.As an additional step, you can optionally run the command
DevEnv.exe /setup
in Developer Command Prompt for VS (as an Administrator) if the above step doesn't resolve the issue.I just had to right click "Add to project" for my new view to pick up on Intellisense.
It looks that there are many reasons produce this problem.
In my case I copied some code/files from another project, after that the Intellisense doesn't work, this because I have different namespace in copied files so that makes Intellisense doesn't work. correct the namespace makes it works again.
In my case this fixed my problem i just change version value from 3 to 2. and its works for me.