Razor Visual Studio Syntax Highlighting is no longer working

Dylan O'Toole 5 Reputation points

Hi I updated my visual studio to begin working with .NET 8. However, in doing so the syntax highlighting on my .razor pages has stopped working. Any advice on how to resolve this?

User's image

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
4,869 questions
{count} vote

3 answers

Sort by: Most helpful
  1. Anna Xiu-MSFT 27,731 Reputation points Microsoft Vendor

    Hi @Dylan O'Toole, 

    Welcome to Microsoft Q&A! 

    What is your project type?

    Please try the following workarounds:

    1. Disable all installed extensions under Extensions > Manage Extensions > Installed.
    2. Open Visual Studio Installer > More > Repair your VS.
    3. Enter “devenv /ResetSettings” at Developer Command Prompt for VS 2022 to restore your Visual Studio default settings
    4. Create new project and check it again.
    5. For code with a gray background, you can disable it via Tools > Options > Environment > Fonts and Colors > Display items: Razor Code Background > change the Item background



    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". 
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.



  2. Patrick Kühnel 5 Reputation points

    Installing The latest Preview version of Visual Studio 2022 (17.9.0 Preview 2.0) fixed the issue for me.

    0 comments No comments

  3. Ondras 0 Reputation points

    Switching on and off the old Razor syntax highlight has helped me: Set True on Tools / Options / Text Editor / HTML / Advanced / Use legacy Razor, restart VS, set False back, and restart VS again.

    Kudos to this answer, that helped me solved the issue after an update to .NET 8.

    0 comments No comments