How to use new c# 8.0 features in Razor views : <p>I've updated my ASP.NET Mvc 5 web application to use the new c# 8.0 features through Visual Studio 2019 and everything works fine until I try to use these new features inside a Razor view.</p>

<p>For example, if I try to use the new switch expression:</p>

<pre class="lang-cs prettyprint-override"><code>@{
    ViewBag.Title = "About";

    var foo = 1;
    var bar = foo switch
    {
        1 =&gt; "one",
        2 =&gt; "two",
        _ =&gt; string.Empty
    };
}
&lt;h2&gt;@ViewBag.Title.&lt;/h2&gt;
&lt;h3&gt;@ViewBag.Message&lt;/h3&gt;

&lt;p&gt;Use this area to provide additional information.&lt;/p&gt;
</code></pre>

<p>The compiler won't complain until I try to reach the page, giving me a compilation error.</p>

<p><a href="https://i.stack.imgur.com/SDb21.png" rel="noreferrer"><img src="https://i.stack.imgur.com/SDb21.png" alt="Compilation error"></a></p>

<p>I suspect that <code>Microsoft.CodeDom.Providers.DotNetCompilerPlatform</code> must be updated but it seems that there is no update available.</p>

<p>Is there any way to use c# 8.0 language features in Razor views?</p>
