title: How to fix 'Bad Request (400)' error when POSTing JSON payload in ASP.NET Core?
body: <p>I am developing a razor page which implements a named handler method. I post some JSON encoded data to the named handler method. However, I get a 400 bad request response in response.</p>
  
  <p>I have tried using different JSON payloads and different method signatures so far but alas, nothing has worked.</p>
  
  <p>Here is a snub of my method:</p>
  
  <pre><code>        [HttpPost]
          public IActionResult OnPostContextFreeGrammarPartial() {
              var grammarModel = new ContextFreeGrammarModel();
  
              return new PartialViewResult() {
                  ViewName = "_ContextFreeGrammar",
                  ViewData = new ViewDataDictionary&lt;ContextFreeGrammarModel&gt;(ViewData, grammarModel)
              };
          }
  </code></pre>
  
  <p>And here is an example request:</p>
  
  <p><img src="https://i.imgur.com/w0YlddR.png" alt="The sent HTTP request"></p>
  
  <p>I am expecting the handler method to be successfully executed but instead the server or browser simply throws a 400 response before the method even begins to execute.</p>
  
  <p>What am I missing?</p>