Reputation: 6433
I am trying to bind to the parent of a certain object type using WebAPI BindParameter. I am able to bind to the object itself (SomeObject), but not its parent (SomeOtherObject). This would cause me to have to have a specific BindParameter call for all possible inheritors of SomeObject. Is there a better way to bind the parameter type that would allow me to accomplish this?
The binders:
GlobalConfiguration.Configuration.BindParameter(typeof(SomeObject), new SetTrackerModelBinder());
GlobalConfiguration.Configuration.BindParameter(typeof(SomeOtherObject), new SetTrackerModelBinder()); //Does not work.
The object structure:
public class SomeObject:SomeOtherObject{
}
public class AnotherObject:SomeOtherObject{
}
public class SomeOtherObject{
}
The action:
public void PostStuffs(SomeObject value) {}
Upvotes: 0
Views: 690
Reputation: 57949
You can try looking at my answer to the following post. I do not use ModelBinders though:
WebApi Model Binding For Inherited Types
Upvotes: 1