今天在发布接口的时候出突然出现了一个问题,报错代码为:

1 An exception has occurred while using the formatter 'JsonMediaTypeFormatter' to generate sample for media type 'application/json'.
2 Exception message: Self referencing loop detected for property '******' with type '******'. Path '[0].******[0]'.

经过研究,解决方法如下:

找到相应的属性,添加 attribute:[IgnoreDataMember]


还有时候会出现特殊情况,即使标记以上的attribute也不能解决

具体错误为:

Newtonsoft.Json.JsonSerializationException 时 Self referencing loop detected for property *****

可以在web api的config中(WebApiConfig.cs)添加一下代码,用以过滤掉此问题

奉上代码:

1   config.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;

最新文章

  1. 随机记录工作中常见的sql用法错误(一)
  2. PHP webservice的使用
  3. Prince2七大原则(4)
  4. 【 2013 Multi-University Training Contest 2 】
  5. php连接sql server
  6. makefile自动生成依赖关系
  7. sublime text配置记录
  8. smali语法中文版
  9. R语言与数据分析
  10. clientX,screenX,pageX,offsetX的异同 【转载】
  11. Oracle DataGuard搭建(一)
  12. What is therelationship between @EJB and ejb-ref/ejb-local-ref?
  13. Activity数据传输到服务
  14. UVa 908 - Re-connecting Computer Sites
  15. linux下的数据库管理工具phpmyadmin安装以及文件大小限制的配置修改
  16. ping 返回的TTL数值代表什么?
  17. Oracle 12c 添加scott用户
  18. rocketmq 学习记录-2
  19. oracle如何链接到另外一个数据库DB_LINK
  20. java基础-day5

热门文章

  1. php5.6.40编译安装
  2. Python:基础知识
  3. HDU 1203 I NEED A OFFER!(01背包+简单概率知识)
  4. 编译最新的SQLite 3.8.4.3为一个DLL
  5. Android 网络编程之---HttpClient 与 HttpURLConnection 共用cookie
  6. SAP调用RestfulApi接口接收数据
  7. Express app.listen 函数了解
  8. Selenium 爬取全国水质周报Word
  9. 欧几里得算法(及扩展)&&快速幂(二分+位运算)
  10. C指针乱谈(1)