Take a look at this question What is the equivalent of MVC's DefaultModelBinder in ASP.net Web API? for some detail on where your bindings are going to be happening.
I suspect though that your Model
is being passed in the message body?
If it is then WebApi will use a formatter to deserialise your types and process the model, the defaults being XmlMediaTypeFormatter
, JsonMediaTypeFormatter
or FormUrlEncodedMediaTypeFormatter
.
If you are posting the model in the body then depending on your requested or accepted content-type is (application/xml, application/json etc) you may need to customise the serialiser settings or wrap or implement your own MediaTypeFormatter
.
If you are using application/json then you can use JsonConverters
to customise the serialisation of your UserInfo class. There is an example of this here Web API ModelBinders - how to bind one property of your object differently and here WebApi Json.NET custom date handling
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)
{
//
}
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
//
}
}