title: How do I do a custom modelbinder when binding from body?
body: <p>I've been trying to experiment with model binding to make our API easier to use. When using the API I can't get the model binding to bind when the data is in the body, only when it is part of the query.</p>
  
  <p>The code I have is:</p>
  
  <pre><code>public class FunkyModelBinder : IModelBinder
  {
      public bool BindModel(HttpActionContext actionContext, ModelBindingContext bindingContext)
      {
          var model = (Funky) bindingContext.Model ?? new Funky();
  
          var hasPrefix = bindingContext.ValueProvider
                                        .ContainsPrefix(bindingContext.ModelName);
          var searchPrefix = (hasPrefix) ? bindingContext.ModelName + "." : "";
          model.Funk = GetValue(bindingContext, searchPrefix, "Funk");
          bindingContext.Model = model;
          return true;
      }
  
      private string GetValue(ModelBindingContext context, string prefix, string key)
      {
          var result = context.ValueProvider.GetValue(prefix + key);
          return result == null ? null : result.AttemptedValue;
      }
  }
  </code></pre>
  
  <p>When looking at the <code>ValueProvider</code> property on the <code>bindingContext</code> I only see <code>QueryStringValueProvider</code> and <code>RouteDataValueProvider</code> which I think means that if the data is in the body I won't get it. How should I do this? I would like to support posting data as either json or form-encoded. </p>