Given the ASP.NET Web API route:
example/{Id}
Which maps to the following ApiController action method:
public void Example(Model m)
{
...
}
With the model class defined as:
public class Model
{
public int Id { get; set; }
public string Name { get; set; }
}
When I post JSON { "Name": "Testing" }
to the URL /example/123
then Id
property of the Model
object is not bound. It remains as 0 instead of 123.
How can I make the model binding also include values from the route data? I'd prefer not having to write custom model binders for what seems like a common use case. Any ideas would be greatly appreciated. Thanks!