Reference Loop Handling in .Net Core (C#) While Returning Data (NewtonSoft)

Code Snippets 4 U

It uses Newtonsoft’s JSON package. The configuration has to be done in ‘ConfigureServices’ method

services
 .AddMvc()
 .AddJsonOptions(options => options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore)
 .SetCompatibilityVersion(CompatibilityVersion.Version_2_2);

Leave a Reply

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

ninety two − 89 =