Jeff Stewart
Jeff Stewart

Reputation: 933

What should a BindModel() implementation do?

I've been reading the MVC 3 source code trying to understand what semantics I should adhere to if I override DefaultModelBinder.BindModel() or even implement IModelBinder.BindModel().

It's unclear to me what "state" BindModel() should leave other objects in once it's done with its work. Sure it's suppose to return a value representing some interpretation of ValueProvider data, but what side effects is it supposed to have? For example:

DefaultModelBinder has so many semantics built into its plumbing that it makes overriding anything it feel very dangerous (i.e. I feel like I can't override anything without violating the Liskov principle). Lack of documentation doesn't help.

Upvotes: 3

Views: 3182

Answers (1)

Pierrick
Pierrick

Reputation: 37

If you need custom binding I would implement the IModelBinder interface and do what's necessary to build your object.

Upvotes: 0

Related Questions