当我尝试在招摇的帮助部分中查看我的api时收到此错误消息。我需要添加一些内容来阻止此错误吗?
Response Formats
application/json
Sample:
An exception has occurred while using the formatter 'JsonMediaTypeFormatter' to generate sample for media type 'application/json'. Exception message: Self referencing loop detected with type 'Model.Disease'. Path '[0].Types[0].List'.
text/json
Sample:
An exception has occurred while using the formatter 'JsonMediaTypeFormatter' to generate sample for media type 'text/json'. Exception message: Self referencing loop detected with type 'Disease'. Path '[0].Types[0].List'.
application/xml
Sample:
An exception has occurred while using the formatter 'XmlMediaTypeFormatter' to generate sample for media type 'application/xml'. Exception message: There was an error generating the XML document.
text/xml
Sample:
An exception has occurred while using the formatter 'XmlMediaTypeFormatter' to generate sample for media type 'text/xml'. Exception message: There was an error generating the XML document.
答案 0 :(得分:2)
GuidelineDataLayer.Model.Disease是您自己的代码?您的对象中有一个循环引用,该引用防止模型序列化。再次检查代码,确保没有两个指向彼此的类。