title: Posting JavaScript objects with Ajax and ASP.NET MVC
body: <p>How can I post a list from view to controller using ajax? I have this code in client side:</p>
  
  <pre><code>    $(".js-save").click(function (e) {
          e.preventDefault();
          var button = $(this);
          var lstERegistroVenta = [];
          var ERegistroVenta = new Object();
          ERegistroVenta.IdProducto = 1;
          ERegistroVenta.IdInventario = 2;
          ERegistroVenta.MontoProducto = 12.5;
          ERegistroVenta.CantidadProducto = 1;
          ERegistroVenta.MontoTotalSinIGV = 20.5
          ERegistroVenta.MontoTotal = 23.5
          lstERegistroVenta.push(ERegistroVenta);
          $.ajax({
              dataType: 'json',
              type: 'POST',
              url: "/API/Inventario/Venta/1",
              data: JSON.stringify({ lstERegistroVenta: lstERegistroVenta }),
              success: function () {
                  toastr.success("Correcto");
              },
              error: function () {
                  toastr.error("Error");
              }
          });
      });
  </code></pre>
  
  <p>When I try to pass the data I receive only empty list. In server side I have this API</p>
  
  <pre><code>[HttpPost]
      [Route("API/Inventario/{Venta}/{IdProducto}")]
      public IHttpActionResult AsignarProducto(int IdProducto,List&lt;ERegistroVenta&gt; lstERegistroVenta)
      {
          return Ok();
      }
  
  public class ERegistroVenta
  {
      public int IdProducto { get; set; }
      public int IdInventario { get; set; }
      public double MontoProducto { get; set; }
      public int CantidadProducto { get; set; }
      public double MontoTotalSinIGV { get; set; }
      public double MontoTotal { get; set; }
  }
  </code></pre>