Entity framework self referencing loop detected

by February 15, 2016 0 comments
Option 1 
 Just add this to the Application_Start in Global.asax

 HttpConfiguration config = GlobalConfiguration.Configuration; config.Formatters.JsonFormatter .SerializerSettings .ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;

This is the correct way. it will ignore the reference pointing back to the object.

Option 2 

Just apply the [JsonIgnore] attribute to the navigation property you don't want to be serialised.

An Nguyen

Developer

Sharing daily exciting lesson learned and posts about .NET, SQL Server, HTML, Javascript - jQuery, CSS - Bootstrap, SalesForce CRM, Kentico CMS and so on.

0 comments :

Post a Comment