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

后端 未结 6 926
执念已碎
执念已碎 2021-02-04 16:07

In my web api when i run project for get data from database got this error .net core 3.1

JsonException: A possible object cycle was detected which is not

6条回答
  •  走了就别回头了
    2021-02-04 16:38

    following code is working for me in dotnet 5.0 :

      services.AddControllersWithViews()
                            .AddJsonOptions(o => o.JsonSerializerOptions
                            .ReferenceHandler = ReferenceHandler.Preserve);
    

提交回复
热议问题