I don't seem to be able to find any authoritative, up-to-date (i.e. for 1.0 final) documentation for the capabilities of the standard model-binder in ASP.NET MVC, particularly with respect to binding complex objects involving collections (and the naming requirements this places on the HTML form)
I have found a blog post from Phil Haack (http://haacked.com/archive/2008/10/23/model-binding-to-a-list.aspx), but it has a note at the top to say it's out of date and will be updated. There was also a useful answer here: Custom Model Binder for Complex composite objects HELP but I couldn't work out how he knew that stuff.
This page: http://www.asp.net/learn/mvc/#MVC_ActionFilters is titled 'Action filters and Model Binders', but only actual contains information about filters.
Am I reduced to reading the source or buying the new 'Gang of Foreheads' book (and hoping it's better than the other Wrox books I've made the mistake of buying in the past)? Or have I missed a good reference somewhere?
Model binding is a well-designed bridge between the HTTP request and the C# action methods. It makes it easy for developers to work with data on forms (views), because POST and GET is automatically transferred into a data model you specify. ASP.NET MVC uses default binders to complete this behind the scene.
In the MVC pattern, Model binding maps the HTTP request data to the parameters of a Controllers action method. The parameter can be of a simple type like integers, strings, double etc. or they may be complex types. MVC then binds the request data to the action parameter by using the parameter name.
For binding complex objects involving collections, check out my answer to this question.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With