zoukankan      html  css  js  c++  java
  • Asp.Net Core报错System.Text.Json.JsonException: A possible object cycle was detected which is not supp(配置导航属性的时候出现的错误)

    Asp.Net Core报错:System.Text.Json.JsonException: A possible object cycle was detected which is not supported. This can either be due to a cycle or if the object depth is larger than the maximum allowed depth of 32

    检测到不支持的可能对象循环。这可能是由于周期或物体深度大于最大允许深度32。

    这是由于进行了对象嵌套或ef 查询进行了预加载(关联加载)引起的,就像解释说的“对象循环”,层级太深解析不了。

    解决方法:

    1. 添加 Microsoft.AspNetCore.Mvc.NewtonsoftJson 包
    2. Startup中添加服务,忽略循环引用
       services.AddControllers().AddNewtonsoftJson(option =>
                    //忽略循环引用
                    option.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore
                );



  • 相关阅读:
    Vue基础
    Document
    Document
    Document
    Document
    Document
    Document
    Document
    Document
    Document
  • 原文地址:https://www.cnblogs.com/qqhfeng/p/14176575.html
Copyright © 2011-2022 走看看