title: Can I post a JSON model from html.raw to controller?
body: <p>I have a model I am passing to a view and using Html.Raw to encode it into a JSON object:</p>
  
  <pre><code> var model = @Html.Raw(Json.Encode(Model));
  </code></pre>
  
  <p>On the page I fill various portions of the model from fields in the page:</p>
  
  <pre><code> model.ProductId = $("#txtProductId").val();
  </code></pre>
  
  <p>and then try to post it to the controller that way with ajax:</p>
  
  <pre><code> $.ajax({
     type: 'POST',
     url: '@Utl.Action("AddProducts"),
     data: JSON.stringify(model),
     dataType: 'json',
       //etc
  </code></pre>
  
  <p>but it is never making it to the controller method:</p>
  
  <pre><code> [HttpPost]
   public ActionResult AddProducts(ProductModel, model)
   {
         //do stuff with the model data
   }
  </code></pre>
  
  <p>Can anyone help me out here and explain how I have to changs things to get the model to post?</p>
  
  <p>My models, simplified:</p>
  
  <pre><code> public class OrderModel {
      public ProductModel Product {get;set;}
      public PersonModel Person {get;set;}
      public List&lt;ProductModel&gt; Products {get;set;}
   }
  
   public class ProductModel {
      public string Partno {get;set;}
      public int Quantity {get;set;}
        /// etc
    }
  
    public class PersonModel {
       public string Surname {get;set;}
       public string GivenName {get;set;}
       public string Address {get;set;}
         /// etc
    }
  </code></pre>