title: .Net Core 3.1 fails to bind properties while using ajax call before submitting the page
body: <p>I'm using .net core 3.1 razor pages. I have a page with a property. I'm using a jQuery ajax call in my page. Sometimes though my field was filled, but the property got null in my PostAsync method. After spending much time, I found that <code>MyProperty</code> was null (not bound) when I called my $.ajax function in the page before submitting it! Is it a bug in .net core or have I forgotten some settings?</p>
  <p>MyPage.chtml:</p>
  <pre><code>...
  &lt;form method=&quot;post&quot;&gt;
      My Property: &lt;input asp-for=&quot;MyProperty&quot; /&gt;&lt;br /&gt;
      &lt;button id=&quot;doAction&quot; type=&quot;button&quot;&gt;Do some action in server&lt;/button&gt;&lt;br /&gt;
      &lt;button type=&quot;submit&quot;&gt;Submit&lt;/button&gt;
  &lt;/form&gt;
  &lt;script&gt;
     $(document).ready(function() {
          $('#doAction').click(function(){
              $.ajax(
                  '/api/myaction/doSomeAction/2',
                  {
                      type: 'POST',
                      success: function() { alert('Some action done successfully.'); }
                  }
          });
     });
  &lt;/script&gt;
  ...
  </code></pre>
  <p>MyPage.chtml.cs:</p>
  <pre><code>[BoundProperty]
  public string MyProperty { get; set; }
  ...
  public async Task&lt;IActionResult&gt; OnPostAsync()
  {
      var temp = MyProperty;
      ...
  }
  </code></pre>
  <p>MyAction controller class:</p>
  <pre><code>[Route( &quot;api/[controller]&quot; )]
  [ApiController]
  public class MyActionController : Controller
  {
     [HttpPost( &quot;doSomeAction/{code?}&quot; )]
     public async Task&lt;dynamic&gt; PostAsync( int code )
     {
          // do some actions...
     }
  }
  </code></pre>
  <p>Startup.cs:</p>
  <pre><code>public void Configure( IApplicationBuilder app , IWebHostEnvironment env )
  {
      ...
      app.UseEndpoints( endpoints =&gt;
          {
              endpoints.MapRazorPages();
              endpoints.MapControllerRoute( &quot;default&quot;, &quot;{controller}/{action}/{id?}&quot; );
          } );
      ...
  }
  </code></pre>
  <p>Scenarios:</p>
  <ol>
  <li>Fill MyProperty with <code>&quot;MyValue&quot;</code> and submit form =&gt; <code>MyProperty == &quot;MyValue&quot;</code> (OK).</li>
  <li>Fill MyProperty with <code>&quot;MyValue&quot;</code>; click <strong><code>doAction</code></strong> button; then submit form =&gt; <code>MyProperty == null</code> (binding property failed!)</li>
  </ol>