title: Controller receives Null arguments from angularjs service post
body: <p>I'm having an issue posting data to my controller using angularjs.</p>
  
  <p>The data looks good while debugging, right until it hits my controller and then the arguments being passed in are always null.</p>
  
  <pre><code>public class NewCompArgs {
              public string Name { get; set; }
              public string Description { get; set; }
  
          }
  
          //Tested with [HttpPost] here, and it didn't work
          // Tested using [FromBody]NewCompArgs args, and splitting 
          // out into Name and Decription strings with [FromBody]
          public ActionResult AddNewComponent(NewCompArgs args) 
          {
              Component NewComp = new Component
              {
                  Name = args.Name,
                  Description = args.Description
              };
              _context.Add(NewComp);
              _context.SaveChanges();
              return Json(NewComp);
          }
  </code></pre>
  
  <p>NewCompArgs args is null every time. </p>
  
  <p>Here is the service I use to hit my controller:</p>
  
  <pre><code>app.factory('Components', function ($http, $q) {
      var service = {};
  
      service.AddNewComponent = function (args) {
          var deferred = $q.defer();
          $http.post('/Components/AddNewComponent', { args: args }).then(function (response) {
              deferred.resolve(response.data);
          });
          return deferred.promise;
      };
      return service;
  });
  </code></pre>
  
  <p>Here is the angular controller function:</p>
  
  <pre><code>$scope.newComponent = function () {
          Components.AddNewComponent($scope.compArgs).then(function (response) {
          });
      }
  </code></pre>
  
  <p>Just an example of the data I'm getting during debugging</p>
  
  <p>Angular Controller:
  <a href="https://i.stack.imgur.com/tIDtt.jpg" rel="nofollow noreferrer">ng controller</a></p>
  
  <p>Angular Service:
  <a href="https://i.stack.imgur.com/Ckrmc.jpg" rel="nofollow noreferrer">ng service</a></p>
  
  <p>MVC Controller:
  <a href="https://i.stack.imgur.com/ljCPF.jpg" rel="nofollow noreferrer">MVC Controller</a></p>
  
  <p>Any advice is greatly appreciated!</p>