当前位置: 代码迷 >> Web前端 >> web API 异常处理The 'ObjectContent`1' type failed to serialize
  详细解决方案

web API 异常处理The 'ObjectContent`1' type failed to serialize

热度:363   发布时间:2013-10-29 12:07:57.0
web API 错误处理The 'ObjectContent`1' type failed to serialize

just added this three lines in my WebApiConfig.cs file...



var json = config.Formatters.JsonFormatter;

json.SerializerSettings.PreserveReferencesHandling = Newtonsoft.Json.PreserveReferencesHandling.Objects;

config.Formatters.Remove(config.Formatters.XmlFormatter);



After this codes were added.the Return XML will be transferred to Json format

  相关解决方案