KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I recently posed a question here on Stack Overflow about finding the right extensibility point for model binding in the Web API beta. Using a custom provider / IModelBinder gives me full control of model binding and access to the value providers. However, it's really too much control. I just want to control how a couple of values are mapped, and don't want to hand-code model binding that would've otherwise worked just fine. Ultimately, this is what I'd like to be able to do: public class MyCustomModelBinder : IModelBinder { public bool BindModel(HttpActionContext actionContext, ModelBindingContext bindingContext) { // Invoke default model binding // Pull out custom values var value1 = bindingContext.ValueProvider.GetValue("value1"); var value2 = bindingContext.ValueProvider.GetValue("value2"); bindingContext.Model.Value1 = DoCustomStuff(value1); bindingContext.Model.Value2 = DoCustomStuff(value2); return true; } ... // Define DoCustomStuff } It looks like it's pretty hard to get ahold of a default provider for the WebAPI. Does anyone know if it's accessible and how it should be accessed here in a custom model binder?
Tags (comma-separated)
Save Edits
Cancel