title: Razor error : does not contain a definition for
body: <p>I am a Razor newbie, just can't run sample copied from : <a href="https://docs.microsoft.com/en-us/aspnet/core/razor-pages/?view=aspnetcore-2.2&amp;tabs=visual-studio" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/aspnet/core/razor-pages/?view=aspnetcore-2.2&amp;tabs=visual-studio</a></p>
  
  <p>My index.cshtml:</p>
  
  <pre><code>@page
  @model IndexModel
  
  &lt;h2&gt;Separate page model&lt;/h2&gt;
  &lt;p&gt;
      @Model.Message
  &lt;/p&gt;
  </code></pre>
  
  <p>My index.cshtml.cs</p>
  
  <pre><code>using Microsoft.AspNetCore.Mvc.RazorPages;
  using System;
  
  namespace aspnetcoreapp.Pages
  {
      public class IndexModel : PageModel
      {
          public string Message { get; private set; } = "PageModel in C#";
  
          public void OnGet()
          {
              Message += $" Server time is { DateTime.Now }";
          }
      }
  }
  </code></pre>
  
  <p>But when I browse this page I receive this error :</p>
  
  <blockquote>
    <p>An error occurred during the compilation of a resource required to
    process this request. Please review the following specific error
    details and modify your source code appropriately.
    C:\temp\aspnetcoreapp\Pages\Index.cshtml</p>
    
    <p>'IndexModel' does not contain a definition for 'Message' and no
    extension method 'Message' accepting a first argument of type
    'IndexModel' could be found (are you missing a using directive or an
    assembly reference?)
    +
        @Model.Message</p>
  </blockquote>