Zapobiegaj $ id / $ ref podczas serializacji obiektów za pomocą Web API i JSON.NET

Nie mogę zapobiec używaniu Web API / JSON.NETNewtonsoft.Json.PreserveReferencesHandling.Objects podczas serializowania obiektów. Innymi słowy, $ id / $ ref są zawsze używane w obiektach serializowanych, pomimo korzystania z następujących ustawień:

public class MvcApplication : System.Web.HttpApplication {

    protected void Application_Start () {
        WebApiConfig.Register(GlobalConfiguration.Configuration);
    }

}

public static class WebApiConfig {

    public static void Register (HttpConfiguration config) {
        JsonMediaTypeFormatter jsonFormatter = config.Formatters.OfType<JsonMediaTypeFormatter>().Single();
        jsonFormatter.UseDataContractJsonSerializer = false;
        jsonFormatter.SerializerSettings.Formatting = Newtonsoft.Json.Formatting.Indented;
        jsonFormatter.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;
        jsonFormatter.SerializerSettings.PreserveReferencesHandling = Newtonsoft.Json.PreserveReferencesHandling.None;
    }

}

Jakieś pomysły?

questionAnswers(5)

yourAnswerToTheQuestion