.Net Core 3.0 possible object cycle was detected which is not supported
回答1
Instead of using NewtonsoftJson I used System.Text.Json.Serialization
For .Net Core 3.1
In Startup.cs
public void ConfigureServices(IServiceCollection services)
{
..........
.......
services.AddControllers().AddJsonOptions(options =>
{
options.JsonSerializerOptions.ReferenceHandler = ReferenceHandler.IgnoreCycles;
options.JsonSerializerOptions.WriteIndented = true;
});
}
For .Net 6
In Program.cs
builder.Services.AddControllers().AddJsonOptions(options =>
{
options.JsonSerializerOptions.ReferenceHandler = ReferenceHandler.IgnoreCycles;
options.JsonSerializerOptions.WriteIndented = true;
});