Razor Visual Studio Syntax Highlighting is no longer working

Dylan O'Toole 5 Reputation points
2023-12-01T10:17:13.7333333+00:00

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
    2023-12-01T13:18:59.4266667+00:00

    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

    Sincerely,

    Anna


    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
    2024-01-01T22:57:13.2066667+00:00

    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
    2024-04-30T13:25:12.0233333+00:00

    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