且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何停止.Net Core Web API中的自引用循环?

更新时间:2023-02-15 21:57:56

好吧...我终于找到了一些参考资料.解决方案是:

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
        );

    ...
}

我从此处