fsl
fsl

Reputation: 831

ASP.NET MVC 3 model binding of complex object

Considering MVC model binding of complex objects in general. Will the normal model binding of a complex object fail if there exists a property for which there is no matching form value?

Does anyone have a concise description of the model binding algorithm?

Upvotes: 0

Views: 227

Answers (1)

Jan
Jan

Reputation: 16042

When you have a controller parameter which is a class, the DefaultModelBinder will try to create an instance of it and fill the properties with data from the request.

Even when there is not a single value for any property, it will create the object and pass it to your action method.

As stated in the comments, you can download the source of the MVC framework (look for the class DefaultModelBinder) or use a tool like reflector so take a look at the source.

If you have a specific problem, please post some code.

Upvotes: 1

Related Questions