Reputation: 803
I have an interface with some classes that implement it. I need to define a modelbinder for that interface, since I'm passing in a list of interface objects.
The defaultmodelbinder can bind the concrete classes just fine. Is there a way I can just call the defaultmodelbinder and tell it what type to create?
Upvotes: 0
Views: 567
Reputation: 803
I was able to get this working with the solution described in the following question:
How to model bind a class that implements an interface?
Turns out it's the CreateModel method I needed to override.
Upvotes: 1
Reputation: 3199
If I understand you correctly, you can either implement a new ModelBinderProvider and make a decision there on what kind of ModelBinder to call for each type of concrete class. Another way would be to write your own ModelBinder that extends DefaultModelBinder and override the BindModel method. In it, you can call to super.BindModel with the the model you want based on the logic you have.
Upvotes: 0