美文网首页
WebApi Serialization Exception

WebApi Serialization Exception

作者: bin_guo | 来源:发表于2017-05-31 03:57 被阅读0次
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>

相关文章

网友评论

      本文标题:WebApi Serialization Exception

      本文链接:https://www.haomeiwen.com/subject/lhsdfxtx.html