asp web api json serialization returns private properties asp web api json serialization returns private properties json json

asp web api json serialization returns private properties


Are your types marked as [Serializable]? Serializable means that the serializer should serialize all fields - private or public. Try to remove Serializable or else use this line to stop the JSON formatter from recognizing the attribute:

config.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new DefaultContractResolver();