Monday-Friday, 9:00-17:00 +19056243686
 

Solve: A possible object cycle was detected which is not supported

feature image

Solve: A possible object cycle was detected which is not supported

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. at ……

3

work well after installing the package Microsoft.AspNetCore.Mvc.NewtonsoftJson firstly for 3.0 or higher.

services.AddControllersWithViews()
    .AddNewtonsoftJson(options =>
    options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore
);

Try with a new project and compare the differences.

Leave a Reply

Your email address will not be published. Required fields are marked *

Post navigation