How to stop self-referencing loop in .Net Core Web API?

Okay… I finally found some reference material on this. The solution is:

public void ConfigureServices(IServiceCollection services)
{
    ...

    services.AddMvc()
        .AddJsonOptions(
            options => options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore
        );

    ...
}

I got this from here

Leave a Comment