asp.net-mvcmodelbinders

Custom Model Binder


I'd like to create a custom model binder.

Let's say there're 20 properties. I need manualy bind only five of them. I'd like to bind the other 15 properties automatic like the default binder does.

Is this somehow possible ?


Solution

  • Sure, the very least thing you can do is inherit DefaultModelBinder, override the BindModel(...) method and use base.BindModel(...) for whatever you want. After that just provide your own binding logic for anything else.