I need to bind model from request and convert to my custom object, my request data is json and method is post.
This is my method in web api:
public IHttpActionResult Edit([ModelBinder(typeof(KModelBinder))] object data)
My problem is: I cannot access to json from ValueProvider in modelbinder.
public class KModelBinder : IModelBinder {
public bool BindModel(HttpActionContext actionContext, ModelBindingContext bindingContext) {
var valueProvider = bindingContext.ValueProvider;
var valProviderResult = valueProvider.GetValue("id");
// ....
}
}
public IHttpActionResult Edit(MyModelClass data)? It should work out of the box.Editmethod like thispublic IHttpActionResult Edit(T data). If you need more info I'll post it as an aswer.