title: fetch post method with razor page doesn't send body
body: <p>I would like to trasnfer some data from the page to the page model with ajax (fetch api) post.
  I manage to get to &quot;OnPostTest&quot; handler, but I don't recive any data - variable &quot;json&quot; is null.
  Where is my problem?
  Is it on my ajax call or in the razor page model method?
  thanks</p>
  <p>razor page- page model</p>
  <pre><code>public JsonResult OnPostTest(string json)
  {
      return new JsonResult(json);
  }
  </code></pre>
  <p>js</p>
  <pre><code>async function getData() {
      fetch('./test/Test',
          {
              method: &quot;POST&quot;,
              body: JSON.stringify({
                  json: 'yourValue'
              }),
              headers: {
                  'X-CSRF-TOKEN': document.getElementsByName(&quot;__RequestVerificationToken&quot;)[0].value,
                  'Content-Type': 'application/json',
                  Accept: 'application/json',
              }
          })
          .then(function (res) { return res.json(); })
          .then(function (data) { alert((data)) })
  }
  </code></pre>
  <p>razor page</p>
  <pre><code>&lt;form method=&quot;post&quot;&gt;
      &lt;button type=&quot;button&quot; onclick=&quot;getData(this)&quot; value=&quot;1&quot;&gt;send&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  <p>----Edit----
  js</p>
  <pre><code>async function getData() {
      fetch('./test/Test',
          {
              method: &quot;POST&quot;,
              body: JSON.stringify(
                  {
                      name: &quot;myname&quot;,
                      value: 1,
                      date:new Date()
                  }
              ),
              headers: {
                  'X-CSRF-TOKEN': document.getElementsByName(&quot;__RequestVerificationToken&quot;)[0].value,
                  'Content-Type': 'application/json',
                  'Accept': 'application/json',
              }
          })
          .then(function (res) { return res.json(); })
          .then(function (data) { alert((data)) })
  }
  </code></pre>
  <p>razor page - page-model</p>
  <pre><code>public JsonResult OnPostTest([FromBody] ViewModel json)
          {
              return new JsonResult(json.Name);
          }
  
          public class ViewModel
          {
              public string Name { get; set; }
              public int Value { get; set; }
              public DateTime date { get; set; }
          }
  </code></pre>