My Razor views in VS2015 RC are not showing the proper coloring for C# code. My project was working fine in VS2013, but it isn't in 2015, and it's not giving me any Intellisense on the C# code. The solution builds and the site runs fine.
I tried the following to no avail
.suo
fileHow can I fix this?
Example:
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.
I had the same problem, the only fix so far is by resetting all user data (C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.exe /ResetUserData
).
NOTE: You will lose all customizations, e.g. keyboard shortcuts and window layouts if you do this!
EDIT: People are saying this only works for RC, not RTM, so you might want to try the other fixes first.
I had the same problem in VS 2015 RTM and was able to fix it by simply loading Visual Studio in Safe Mode by:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.exe /SafeMode
then closing and reopening it normally.
After Updating Visual Studio 2015 Update 1 I had same issue. I tried all the answers but did not work for me.
The fix for me was going to programs and properties > Visual Studio community edition > Change. I clicked on modify.
In the list make sure to put a check mark on "Microsoft Web Developer Tools" under "Windows and Web Development" .
It was not checked in my list howewer :/
Tools > Options > Text Editor > All Languages > General. Uncheck the Hide advanced members option. Click OK.
Once I did that Intellisense seemed to work for me. I then reset it back and kept functionality. I'm using Visual Studio 2015 enterprise edition.
I had tried ResetUserData and that did not work for me.
I installed Visual Studio Community Edition 2015 (after using Visual Studio Community Edition 2013 for a long time) and faced the same issue. I tried all the above solutions but nothing helped.
Finally, close Visual studio and deleted the following folders -
C:\Users\Allwyn\AppData\Roaming\Microsoft\VisualStudio\14.0
C:\Users\Allwyn\AppData\Roaming\Microsoft\VisualStudio\14.0
... and it works now!!!
Running VS 2015 RTM. Neither /ResetUserData nor /SafeMode worked for me. Also had some Productivity Power Tools 2015 related complains with "errors-in-ActivityLog.xml" popup when starting VS.
So, if you have similar symptoms, here's how I fixed it on my machine:
%LOCALAPPDATA%\Microsoft\VisualStudio\
and erase 14.0
folder.P.S. Actually, it took me a couple times to get my intellisense working because I disabled the PowerTools first and it broke VS again when reenabled. So, it requires a complete reinstall. Might be caused by another extension in your case.
This will be the effect if your project is MVC4. See more details here. Also note that this will be corrected in an upcoming release.
How can you tell if your project is MVC4? Open packages.config and scroll to the entry for Microsoft.AspNet.Mvc. If the version listed starts with "4", this means you are using MVC 4.
I had a similar issue, where any razor script wouldn't be highlighted, intellisense wouldn't work and the compiler wouldn't recognise any errors (even where I intentionally put syntax errors in!)
I actually fixed the problem by going to C:/Users/YourUserName/AppData/Local/Temp and deleting everything out of this file, soon as I did that and restarted VS my Razor Views started to work!
Hope that helps!
Friendly reminder to make sure you have correctly used the lowercase @model
at the top of your view, and not @Model
(like I made the mistake of doing).
Lowercase @model
is a directive that strongly types the view to an instance of the class that follows it. Whereas the capitalized Model
is a property of the view that gets the model instance.
Some views were working fine for me, some not at all... The only thing that helped for me:
I tried most of the other solutions, too, but they didn't work for me.
I fixed the issue by including the file in the project/solution. I'd overlooked the fact that there's no highlighting/intellisense if it's not included.
I had the same problem and had to download and install "Microsoft ASP.NET and Web Tools" and "Web Essentials". After doing this syntax highlighting and Razor intellisense started working again.
In my Web.config I had this:
<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="LinkApp.Models.Templates"/>
<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="LinkApp" />
</namespaces>
</pages>
</system.web.webPages.razor>
Oddly enough, I moved my custom namespace to the bottom, and that fixed it, like this:
<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" />
<add namespace="LinkApp" />
<add namespace="LinkApp.Models.Templates"/>
</namespaces>
</pages>
</system.web.webPages.razor>
Uninstalled and reinstalled of the following worked for me:
Microsoft.AspNet.Mvc
Microsoft.AspNet.WebPages
Microsfot.AspNet.Razor
I tried the reset userdata, deleting of temp and 14, as well as changing options settings and none of those worked. I even tried repaired and reinstalled. I am using VS 2015 Version 14.0.24720.00 Update 1
You should only remove the ".vs" folder in your project.(The .vs folder is hidden)
Be careful ResetUserData
remove all customization on Visual Studio.
The only thing that worked for me was to change the project's "Output Path" to bin\
(It used to be bin\Debug
):
Properties
and navigate to Build
,Output path:
to bin\
Above doesn't work but I managed with:
Web Developer Tools
for VS 2015, RC, Update 1Web Developer Tools
(it's another version of above)So the problem was that VS installer didn't install Web Developer Tools recognizing already installed, incompatible version as the proper one.
I fixed this problem by updating my project to ASP .NET MVC version 5. But it required some futher manipulations with configuration files. Here I found the step-by-step guide:
I hope this will help.
A non-invasive approach is to check your Views web.config files for the correct Versions. These Web.config files are under app/Area/AreaName/Views or the general app/Views folders. They are different than the project Web.config file.
Here is an example for the latest as of the writing of this comment:
<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" />
What worked for me (VS 2015 Community) was the option suggested in this answer. Running cmd.exe as administrator, I ran the following:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.exe /setup