title: How do I do #nullable enable in an aspnetcore razor view page (.cshtml)
body: <p>Possible Duplicate, but I've been unable to find anything on this.</p>
  <p>I have an asp.net core MVC project, which makes use of normal views using Razor.</p>
  <p>I have some ViewModel objects with nullable reference types, and I'm using the C# 8 null-safety feature to mark those appropriately (e.g. <code>string? Name</code>)</p>
  <p>My problem is, when I use those variables in a <code>cshtml</code> file, as strongly typed Models, the null-safety isn't applied because I haven't enabled it for the file.</p>
  <p>If it were a <code>.cs</code> file, I'd stick <code>#nullable enable</code> at the top, but what can I do for razor pages?</p>
  <hr />
  <p>Update to clarify: If possible, I would like null-safety warnings on all @code blocks throughout the razor file. <a href="https://stackoverflow.com/a/64640554/234">Tân's answer</a> shows how to enable it for a specific block, but I'd like it for something like this</p>
  <pre><code>&lt;span&gt;@Model.Name.ToUpper()&lt;/span&gt;
  </code></pre>
  <p>Specifically, I'd like a warning on Name.ToUpper() as Name is nullable and I didn't use the ? operator when calling ToUpper</p>