By default you don't need to use neither[Serializble]Nor[DataContract]To work with web API.
ASP. NET Web APIs are not required by default.[Serializble]Or[Datacontract] Mark
Just leave your model as is, and web API wocould serialize all the public properties for you.
ASP. NET web API will automatically help us serialize all public attributes
Only if you want to have more control about what's wrong ded, you then decorate your class[DataContract]And the properties to be encoded[DataMember](Because both DCS and JSON. Net respsect these attributes ).
You can use[DataContract],[DataMember]Mark.
If for some reason, you need[Serializble]On your class (I. e. you are serializing it into a memory stream for some reason, doing deep copies etc), then you have to use both attributes in conjunction to prevent the backing field names:
For some reason, you must use[Serializble]Mark (for example, save data in couchbase), then you should use[Serializable] and [datacontract.
[Serializable][DataContract]public class Error{ [DataMember] public string Status { get; set; } [DataMember] public string Message { get; set; } [DataMember] public string ErrorReferenceCode { get; set; } [DataMember] public List<FriendlyError> Errors { get; set; }}
Link: http://stackoverflow.com/questions/12334382/net-webapi-serialization-k-backingfield-nastiness