title: ASP.NET Core 2, jQuery POST data null
body: <p>I use <code>jQuery</code> and send data with the <code>POST</code> method. But in the server method the values are not coming. What could be the error?</p>
  
  <p><strong>client</strong></p>
  
  <pre><code>$.ajax({
      type: "POST",
      contentType: "application/json; charset=utf-8",
      url: "./AddTag",
      dataType: "json",
      data: "{'parentId':42,'tagName':'isTagName'}",
      success: function (response) {
          // ...
      }
  });
  </code></pre>
  
  <p><strong>server</strong></p>
  
  <pre><code>[HttpPost]
  public JObject AddTag(int parentId, string tagName)
  {
      dynamic answer = new JObject();
      List&lt;LogRecord&gt; logs = new List&lt;LogRecord&gt;();
      answer.added = fStorage.Tags.AddTag(parentId, tagName, logs);
      return answer;
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/56gaK.png" rel="noreferrer"><img src="https://i.stack.imgur.com/56gaK.png" alt="Brackpoint"></a></p>
  
  <p><a href="https://i.stack.imgur.com/bNLVh.png" rel="noreferrer"><img src="https://i.stack.imgur.com/bNLVh.png" alt="Chrome"></a></p>
  
  <p><strong>fixed</strong>
  Thank you all very much. I understood my mistake. I fixed the client and server code for this:</p>
  
  <pre><code>let tag = {
          "Id": 0,
          "ParentId": 42,
          "Name": isTagName
      };
  $.ajax({
      type: "POST",
      contentType: "application/json; charset=utf-8",
      url: "./AddTag",
      dataType: "json",
      data: JSON.stringify(tag),
      success: function (response) {
          // ...
      }
  });
  </code></pre>
  
  <p><strong>server</strong></p>
  
  <pre><code>    [HttpPost]
      public JObject AddTag([FromBody] Tag tag)
      {
          dynamic answer = new JObject();
          List&lt;LogRecord&gt; logs = new List&lt;LogRecord&gt;();
  
          answer.added = fStorage.Tags.AddTag(tag.ParentId, tag.Name, logs);
          answer.logs = Json(logs);
  
          return answer;
      }
  </code></pre>
  
  <p>The class has added</p>
  
  <pre><code>public class Tag
  {
      public int Id { get; set; }
      public int ParentId { get; set; }
      public string Name { get; set; }
      public List&lt;Tag&gt; ChildsList { get; set; }
      [NonSerialized]
      public Tag ParrentTag; 
  }
  </code></pre>