Visual Studio 2015 not syntax highlighting razor n

2019-01-05 08:10发布

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:

21条回答
Lonely孤独者°
2楼-- · 2019-01-05 08:55

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!

查看更多
冷血范
3楼-- · 2019-01-05 08:56

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.

查看更多
仙女界的扛把子
4楼-- · 2019-01-05 08:56

Some views were working fine for me, some not at all... The only thing that helped for me:

  • Closing VS
  • Deleting C:\Users\%username%\AppData\Local\Temp
  • Restarting VS
  • Problem solved

I tried most of the other solutions, too, but they didn't work for me.

查看更多
登录 后发表回答