简体   繁体   English

为什么VS19中的razor代码不高亮in.cshtml文件?

[英]Why is razor code in VS19 not highlighting in .cshtml file?

I'm using Visual Studio 2019, v16.11.8 Preview 1.0 to work on MVC projects.我正在使用 Visual Studio 2019 v16.11.8 Preview 1.0 来处理 MVC 项目。 At some point my razor code stopped appearing highlighted in .cshtml files, making HTML and C# difficult to tell apart.在某些时候,我的 razor 代码停止在.cshtml文件中突出显示,使得 HTML 和 C# 难以区分。 This is how the code looks now:这是代码现在的样子: 在此处输入图像描述

I've checked over the color settings for razor code by going to Tools -> Options -> Environment -> Fonts and Colors -> HTML Razor Code Background , but this and the other related settings looked fine. I've checked over the color settings for razor code by going to Tools -> Options -> Environment -> Fonts and Colors -> HTML Razor Code Background , but this and the other related settings looked fine. I've also tried restarting VS and the machine itself.我也尝试过重新启动 VS 和机器本身。

What is the cause of this and how can I fix it?这是什么原因,我该如何解决?

Found the issue.发现问题。 An experimental Razor editor is enabled by default in the preview.预览版中默认启用实验性 Razor 编辑器。 One of the known issues relates to the coloring. 已知问题之一与着色有关。

To disable the experimental editor go to Tools > Options > Preview Features and scroll down to uncheck Enable Experimental Razor editor (requires restart) .要禁用实验性编辑器 go 到工具 > 选项 > 预览功能并向下滚动以取消选中启用实验性 Razor 编辑器(需要重新启动) Click Ok and restart your VS.单击确定并重新启动您的 VS。

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM