Bind from both Uri and Body

Topics: ASP.NET Web API
Jul 16, 2013 at 10:25 PM
Is it possible to bind a model from both the Uri and Body?

For instance, given the following:
    name: "API Default",
    routeTemplate: "api/{controller}/{id}",
    defaults: new { id = RouteParameter.Optional }

public class ProductsController : ApiController
    public HttpResponseMessage Put(UpdateProduct model)


public class UpdateProduct 
    int Id { get; set;}
    string Name { get; set; }
Is it possible to create a custom binder so that a PUT to
with a JSON body of:
    "Name": "Product Name"
will result in the UpdateProduct model populated with Id = 1 and Name = "Product Name"?

I understand that I could change the action signature to
public HttpResponseMessage Put(int id, UpdateProduct model)

However I specifically want to bind to a single model object

I tried the MvcActionValueBinder from, however that only works if the mime-type is 'application/x-www-form-urlencoded' not 'application/json'