Windows Dev Center

[Beta] Disabling model binding in ASP.NET Web API Beta

[This sample was created to work around a bug in the Beta release, and is not needed in the latest bits] This sample shows how to disable model binding on specific actions for the ASP.NET Web API Beta (part of the ASP.NET MVC 4), and a scenario where this is required.

C# (1.7 MB)
3,072 times
Add to favorites
E-mail Twitter Digg Facebook
Sign in to ask a question

  • Status update on model binding...
    2 Posts | Last post June 15, 2012
    • Hi, now that the RC is out, do we still need to disable model binding?
      If not, what should be done instead?
    • Hi Mario, you don't need to disable it anymore. On RC there's a lot less "magic" on how a parameter is bound from the request - it's deterministic. If it's a simple type, it's supposed to come from the URL (unless a [FromBody] attribute is applied to it). If it's a complex type, it's supposed to come from the body (unless it's decorated with [FromUrl]). And if the parameter is read from the body by a formatter, the formatter will "own" the whole content, so whatever the formatter wrote, it should be able to read it back. The post at has more information on how the model binding is done.