razorintellisensevisual-studio-2022

Intellisense in razor/cshtml files not working (Visual Studio 2022)


We are used to intellisense everywhere and suddenly it doesn't work.

To my frustration, this was only the case on my work computer, the installation at home does work. Both has been updated to version 17.5.0, but I think the problem also existed with the previous version (on my work computer) - it's been a while since I did any Razor coding.

I've searched for like issues, but every question were related to older versions of VS.

I finally found a mention of a new version of the Razor editor, with description of how to deactivate this and reactivate the old one. To my surprise this worked:

Open Tools / Options and navigate to Text Editor / HTML / Advanced, here you find a setting: "Use legacy Razor editor for ASP.NET CORE". Change the setting to true and intellisense are back!

Nice to find a solution, but!

Any suggestions how to actually solve this (not just work-around), will be appreciated!


Solution

  • OK - finally an update to handle this issue!

    Update Visual Studio to 17.8.+ (.Net 8/C# 12 etc) - in this version they (the Visual Studio team) has included a setting to enable colors for the new Razor editor, see the release notes here!

    If you has activated to old editor, deactivate: Tools/Options/Text Editor/HTML/Advanced - Set Razor setting to false (restart VS).

    To activate colors: Tools/Options/Text Editor/Razor (Asp.NET Core)/Advanced - Set Background for C# code to true.

    By the way: This setting defaults to false, so not active on new installations!