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
- disabling all Visual Studio extensions
- deleting my
.suo
file - removing the project and re-adding it to the solution
How can I fix this?
Example:
In my Web.config I had this:
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.
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 capitalizedModel
is a property of the view that gets the model instance.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.
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'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 found15.0_9a1c4a06
inside the AppData folder.