title: ajax post data null in mvc core controller method
body: <p>I faced this problem here , but I can not solve it . I searched a lot and tried every solution I found on the similar post . so if there is any help to my case . my part of my app which I found the problem in , first here is my view , I have Categories dropdown when I choose a category I will load the property of that value in a table.</p>
  <pre><code>@model Demo.Models.ViewModel.DeviceVM
  
  &lt;form method=&quot;post&quot;&gt;
  
      &lt;input hidden asp-for=&quot;@Model.device.ID&quot; /&gt;
  
      &lt;div class=&quot;border p-3&quot;&gt;
  
          @*putting the page label*@
          &lt;div class=&quot;row&quot;&gt;
              &lt;h3 class=&quot;text-info pl-3 pb-3&quot;&gt;Create Device&lt;/h3&gt;
          &lt;/div&gt;
  
                  @*fifth Row =&gt; Category List*@
                  &lt;div class=&quot;form-group row&quot;&gt;
  
                      @*field Label*@
                      &lt;div class=&quot;col-4&quot;&gt;
                          &lt;label asp-for=&quot;@Model.device.CategoryID&quot;&gt;&lt;/label&gt;
                      &lt;/div&gt;
  
                      @*field Text*@
                      &lt;div class=&quot;col-8&quot;&gt;
  
                          &lt;select asp-for=&quot;@Model.device.CategoryID&quot; asp-items=&quot;@Model.CategoryDropDown&quot; class=&quot;form-control&quot;
                                  id=&quot;CategoryList&quot;&gt;
                              &lt;option value=&quot;&quot;&gt;-- Select Category --&lt;/option&gt;
                          &lt;/select&gt;
                          &lt;span asp-validation-for=&quot;@Model.device.CategoryID&quot; class=&quot;text-danger&quot;&gt;&lt;/span&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
  
  
                  &lt;div class=&quot;form-group row&quot;&gt;
                      &lt;div class=&quot;col-4&quot;&gt;
                          &lt;label&gt;Category Properties&lt;/label&gt;
                      &lt;/div&gt;
                      &lt;div class=&quot;col-8&quot;&gt;
                          &lt;table class=&quot;table table-bordered table-striped&quot;&gt;
                              &lt;thead class=&quot;thead-dark&quot;&gt;
                                  &lt;tr&gt;
                                      &lt;th&gt;Property&lt;/th&gt;
                                      &lt;th&gt;Value&lt;/th&gt;
                                  &lt;/tr&gt;
                              &lt;/thead&gt;
                              &lt;tbody id=&quot;plist&quot;&gt;
  
                              &lt;/tbody&gt;
                          &lt;/table&gt;
                          
                      &lt;/div&gt;
                  &lt;/div&gt;
  
  
  
                  @*Seventh Row =&gt; Buttons*@
                  &lt;div class=&quot;form-group&quot;&gt;
  
                      &lt;div class=&quot;col-8 offset-4 row&quot;&gt;
  
                          @*Save Button*@
                          &lt;div class=&quot;col&quot;&gt;
                              &lt;input type=&quot;submit&quot; value=&quot;Save&quot; asp-action=&quot;Create&quot; class=&quot;btn btn-info w-100&quot; /&gt;
                          &lt;/div&gt;
  
                          @*Back Button*@
                          &lt;div class=&quot;col&quot;&gt;
                              &lt;a class=&quot;btn btn-success w-100&quot; asp-action=&quot;Index&quot;&gt;Back&lt;/a&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
  
                  &lt;/div&gt;
  
              &lt;/div&gt;
  
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/form&gt;
  
  @section Scripts
  {
     
      &lt;script&gt;
  
          $(function ()
          {
  
              $('#CategoryList').on(&quot;change&quot;, function () {
                  var _category = $('#CategoryList').val();
                  var obj = {CategoryID:_category};
                  AjaxCall(&quot;GetCategoryProperty&quot;, JSON.stringify(obj), 'POST').done(function (response) {
                      console.log(JSON.stringify(obj));
                      if (response.length &gt; 0)
                      {
                          console.log(&quot;i'm here &quot;);
                      }
                  }).fail(function (error) {
                      alert(error.StatusText);
                  });                
              });
  
          });
  
          function AjaxCall(url, data, type) {
              return $.ajax({
                  url: url,
                  type: type ,
                  data: data ,
                  contentType: 'application/json; charset=utf-8',
                  dataType:'json'
              });
          }
      &lt;/script&gt;
  
  }
  </code></pre>
  <p>here is my Category Model</p>
  <pre><code>public class Category
  {
      [Key]
      public int ID { get; set; }
  
      [Required,MaxLength(15),Display(Name =&quot;Category Name&quot;)]
      public string CatName { get; set; }
  
      public virtual ICollection&lt;Category_Property&gt; categoryprperties {get;set;}
  
  }
  </code></pre>
  <p>here is my Function in the view which always receive 0 in it's parameter</p>
  <pre><code>    [HttpPost]
      public JsonResult GetCategoryProperty([FromBody]int CategoryID)
      {
          DeviceVM obj = new DeviceVM();
  
          var _CategoryProperty = (from cp in _db.Category_Property
                                   join p in _db.Property on cp.PropertyID equals p.ID
                                   where cp.CategoryID == CategoryID
                                   select new { cp.CategoryID, p.Description, cp.PropertyID });
  
  
  
          return Json(_CategoryProperty );
      }
  </code></pre>
  <p>I opened the inspect in the browser I it did not reach the message inside the if block because ajax always send 0 for the category id , which I asking for a help to get work.</p>