WebApi Serialization Exception

2017-05-31  本文已影响0人  bin_guo
SerilizationException.png
  1. Under the file of <code>XXXContext.cs</code>, and In the region of <code>Database Context</code>, append this code inside of <code>XXXContext()</code> constructor method:
    <code>base.Configuration.ProxyCreationEnabled = false;</code>

  2. Or you can Insert the following codes inside of <code>Global.asax file</code>
    <code>
    GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;
    GlobalConfiguration.Configuration.Formatters.Remove(GlobalConfiguration.Configuration.Formatters.XmlFormatter);
    </code>

上一篇 下一篇

猜你喜欢

热点阅读