When I closed the tabs that I opened for this question, which I did not get to the ModelBinderAttribute , I found someone with the answer , You can assign ModelBinderAttribute your view models:
[ModelBinder(typeof(SomeEditorModelModelBinder))] public class SomeEditorModel {
Although this was not quite what I was looking for, it is even more specific than registering it for a controller or controller method.
Update
Thanks to Levy's remark indicating a much better solution. If you consume an object using a custom binder in the MVC action method directly, you can simply decorate this method parameter with the ModelBinder property.
public ActionResult SomeMethod([ModelBinder(typeof(SomeEditorModelBinder))]SomeEditorModel model) { ... }
source share