To enable syntax highlighting on your ASP.NET site follow the steps below:
- Goto prismjs.com and press the Download button.
- Add the next items to the default languages: C#, ASP.NET (C#), Bash + Shell + Shell, C#, Razor C# and SQL.
- Also add the plugin “line-numbers”.
- At the bottom of the page download the prims.js and prism.css files.
In the Shared/_Layout.cshtml add both the prism.js and prism.css file.
In the Index.cshtml view add some code to test it out
<div class="row">
<div class="col line-numbers">
<pre><code class="language-csharp">public class HelloWorld
{
public static void Main(string[] args)
{
Console.WriteLine("Hello, World!");
}
}
</code>
</pre>
</div>
<div class="col">
<pre>
<code class="language-sql">
SELECT * FROM AspNetUsers u
LEFT JOIN AspNetRols on r.Id = u.Id
WHERE ID = 1;
</code>
</pre>
</div>
</div>
The resulting page will look like this

