I'm working on an REST API in ASP.NET. One of the first things I made was a Model Binder for the model, binded with the model by a code like this:
[ModelBinder(typeof(MyModelModelBinder))]
public class MyModel { ... }
And used it in an action
public IHttpActionResult Post(MyModel model) { ... }
I realised, quite suddenly, that after I added the [FromBody] before the parameter type...
public IHttpActionResult Post([FromBody]MyModel model) { ... }
...the Model Binder gets ignored. I tried to debug it by puting a breakpoint on the beginning of the BindModel method and at the beginning of the action and realised that when I call the action I get straight to the action. When I delete the FromBody Attribute the breakpoint in the ModelBinder becomes active again.
Why can't I use both? Why is the FromBody attribute ignoring the ModelBinder?