title: Pass multiple parameters from ajax post to asp.net mvc controller
body: <p>I have a view that I'm binding with knockoutjs. I need to add data dynamically to a list in the viewmodel using ajax post. </p>
  
  <pre><code>            var data = {
                  model: ko.toJS(self.Model),
                  name: name
              }
  
               $.ajax({
                  url: options.url + "AddAdvantage",
                  type: 'POST',
                  dataType: 'json',
                  contentType: 'application/json',
                  data: JSON.stringify(data),
                  traditional: true,
                  success: function (data) {
                      self.UpdateOnChange = false;
                      ko.mapping.fromJS(data, self.Model);
                      self.UpdateOnChange = true;
                  }
              });
  </code></pre>
  
  <p>when the data parameter is passed to the controller action:</p>
  
  <pre><code>[HttpPost]
  public JsonResult AddAdvantage([ModelBinder(typeof(AdvantageModelBinder))] AdvantageViewModel model, string name) {
  }
  </code></pre>
  
  <p>name value is passed, but model is always null</p>
  
  <p>I have tried this:</p>
  
  <pre><code>            var data = {
                  model: ko.toJSON(self.Model),
                  name: name
              }
  </code></pre>
  
  <p>also tried:</p>
  
  <pre><code>            var data = JSON.stringify({
                  model: ko.toJSON(self.Model),
                  name: name
              });
  </code></pre>
  
  <p>same result. </p>
  
  <p>this works fine:</p>
  
  <pre><code>           $.ajax({
                  url: options.url + "AddAdvantage",
                  type: 'POST',
                  dataType: 'json',
                  contentType: 'application/json',
                  data: ko.toJSON(self.Model),
                  traditional: true,
                  success: function (data) {
                      self.UpdateOnChange = false;
                      ko.mapping.fromJS(data, self.Model);
                      self.UpdateOnChange = true;
                  }
              });
  </code></pre>
  
  <p>My ModelBinder</p>
  
  <pre><code>public class AdvantageModelBinder: DefaultModelBinder
  {
      public AdvantageModelBinder()
      {
      }
  
      protected override object CreateModel(ControllerContext controllerContext, ModelBindingContext bindingContext, Type modelType)
      {
          ValueProviderResult value = bindingContext.ValueProvider.GetValue("WizardType");
          Type typeByTypeName = AdvantageModelBinder.GetTypeByTypeName((string)value.ConvertTo(typeof(string)));
          object obj = Activator.CreateInstance(typeByTypeName);
          bindingContext.ModelMetadata = ModelMetadataProviders.Current.GetMetadataForType(() =&gt; obj, typeByTypeName);
          return obj;
      }
  
      public static Type GetTypeByTypeName(string typeName)
      {
          Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
          for (int i = 0; i &lt; (int)assemblies.Length; i++)
          {
              Type type = assemblies[i].GetType(typeName, false, true);
              if (type != null)
              {
                  return type;
              }
          }
          throw new ArgumentException("Can't find the specified type in the loaded assemblies.", typeName);
      }
  }
  </code></pre>
  
  <p>can anyone tell how to fix this?</p>