We have some objects that are marked as [Serializable] , so they can be serialized using traditional methods, but we must have purely serialized in JSON for use with the Web API. Setting IgnoreSerializableAttribute to true will stop Newtonsoft.Json from behaving like Microsoft serializers, and instead it just serializes the public properties.
TL; DR: add this to WebApiConfig.cs:
((Newtonsoft.Json.Serialization.DefaultContractResolver)config.Formatters.JsonFormatter.SerializerSettings.ContractResolver).IgnoreSerializableAttribute = true;
Moderator: Instead of deleting a really good answer to a question that was asked several times, delete the duplicate question. This is a valid answer to the right question.
Richard Apr 28 '16 at 9:24 2016-04-28 09:24
source share