I'm using Expression theme in Visual Studio 2010 Ultimate
on Windows 7
operating system. (Note: Actually, I'm not sure this problem occurs because of the dark theme) A few days ago, I decided to learn ASP.NET MVC 4
and tried to create a small web application. In Visual Studio, I followed this instruction and created a new asp.net mvc 4 web application: File->New->Project->ASP.NET MVC 4 Web Application.
Everything was perfect. But when I opened the Login.cshtml
file, I couldn't even see the razor syntax (expressions which started @
) because of highlighting. Take a look:
Even if I select all the text with CTRL + A in Visual Studio, I barely see the syntax.
Because of that, I can't even start to learn asp.net mvc. I started to look for a solution for this situation on the internet, but I couldn't find any useful answer. In Visual Studio, I looked the Tools->Option->Font and Colors
option, but I couldn't find anything for this either. This problem shows only when I'm working in a View
(for the Razor
). There is no highlighting problem in Model
, Controller
or any other code files.
User ray247 asked a question close enough to my question called Where can I change the Asp.net MVC 3 Razor syntax hightlighting in VS10? but I still can't find a solution. I don't want to stop using my dark theme. It's really good for my eyes.
What is Razor? Razor is a markup syntax that lets you embed server-based code (Visual Basic and C#) into web pages.
Razor supports C# and uses the @ symbol to transition from HTML to C#. Razor evaluates C# expressions and renders them in the HTML output. When an @ symbol is followed by a Razor reserved keyword, it transitions into Razor-specific markup.
Razor is a simple programming syntax for embedding server code in web pages. Razor syntax is based on the ASP.NET framework, the part of the Microsoft.NET Framework that's specifically designed for creating web applications.
Syntax highlighting determines the color and style of source code displayed in the Visual Studio Code editor. It is responsible for colorizing keywords like if or for in JavaScript differently than strings and comments and variable names. There are two components to syntax highlighting: Tokenization: Breaking text into a list of tokens
Go to Tools > Options > Environment > Preview Features and select the Enable experimental Razor editor option: When you go to turn on the new Razor editor you may find that it’s already on. Starting with Visual Studio 16.9 Preview 3 we are slowly rolling out the new Razor editor to different groups of users.
Locate again the ASP.NET and Web Development package and check it, then click the Modify button to install it from scratch. Once done, launch Visual Studio 2017: if everything went well, your Razor pages will now have proper Intellisense and syntax coloring. That’s it!
Both the options run AspNetMVC3Setup.exe and it installs Visual Studio 2010 support for Razor syntax in addition to other components bundled in the exe. What does ASPnetMVC3Setup.exe install for Visual Studio to support the syntax? The ASP.NET MVC 3 installer includes the following components. Components in bold add the support.
You should be able to change the text background for Razor code by:
Tools
-> Options
),Fonts and Colors
" (Under Environment in the treeview at left)Text Editor
" (if that isn't the value already),Razor Code
" from the "Display Items
" listbox, andOK
" to apply the change.There's also an "HTML Server-Side Script" setting that controls the background color of the Razor code delimiters (the @
expression and similar expressions that mark the beginnings of code blocks.)
HTH,
Clay
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With