title: Asp Core .Net 3.1 - Automatic binding to Model in Razor page
body: <p>I have an ASP .Net Core 3.1 WebApp, and I'm trying to use automatic Model binding, but I'm missing something (basic) in how the conventions are followed</p>
  
  <p>Sales.cshtml:</p>
  
  <pre><code>@page
  @model foo.Views.Dashboard.SalesModel
  &lt;div class="container"&gt;
      &lt;h3&gt;@Model.periodMonthSelect&lt;/h3&gt;
  
      &lt;form asp-page="/Dashboards/Sales" method="POST"&gt;
          &lt;input name="periodMonthSelect" type="text" value="July 2020"/&gt;
          &lt;input type="submit"/&gt;
      &lt;/form&gt;
  </code></pre>
  
  <p>Sales.cshtml.cs</p>
  
  <pre><code>namespace foo.Views.Dashboard
  {
      public class SalesModel : PageModel
      {
          [BindProperty]
          public string periodMonthSelect { get; set; }
  
      }
  }
  </code></pre>
  
  <p>DashboardController.cs</p>
  
  <pre><code>public class DashboardController : Controller
  {
      public IActionResult Sales()
      {
          return View();
      }
  
  }
  </code></pre>
  
  <p>In the Controller, if I return <code>new View()</code> I get <code>Object reference not set to an instance of an object</code> because obviously there is no Model object.  However, if I return <code>new View(new SalesModel())</code> the value of the member property <code>periodMonthSelect</code> is, of course, null.</p>
  
  <p>I've been trying to find the answer to this, but it's hard to isolate information relevant only to the new .NET Core 3.1 revision.</p>
  
  <p>I've confirmed that the value for <code>periodMonthSelect</code> is present in the POST request parameters. </p>
  
  <p>How do I get an automatically populated instance of the Model to be passed to the Razor page?</p>