Take a look at this question. What is the equivalent of MVC DefaultModelBinder in the ASP.net web interface? for details of where your bindings will take place.
I suspect your Model is being sent in the body of the message?
If in this case WebApi will use the formatter to deserialize your types and process the model, the default values are XmlMediaTypeFormatter , JsonMediaTypeFormatter or FormUrlEncodedMediaTypeFormatter .
If you send the model to the body, then depending on your requested or accepted type of content (application / xml, application / json, etc.) you may need to configure serializer settings or wrap or implement your own MediaTypeFormatter .
If you are using the / json application, you can use JsonConverters to serialize your UserInfo class. Here is an example of this Web API ModelBinders - how to bind one property of your object in a different way and here WebApi Json.NET personalized data processing
internal class UserInfoConverter : JsonConverter { public override bool CanConvert(Type objectType) { return objectType == typeOf(UserInfo); } public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) {
Mark jones
source share