ASP.NET Web API Serialized JSON Error: "Self Referencing loop" ASP.NET Web API Serialized JSON Error: "Self Referencing loop" json json

ASP.NET Web API Serialized JSON Error: "Self Referencing loop"


The error was caused by the EF creating proxies for the foreign key objects, the default serializer (DataContractSerializer) errors when serializing with proxies. The solution is to add the following line to the Global.asax.cs file:

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

While @SKall's answer did solve the problem, it didn't solve it throughout the project, just to properties that I gave the IgnoreDataMember attribute.


Mark the references with IgnoreDataMember attribute and let us know if that helped.

[IgnoreDataMember]public virtual Equipment Equipment { get; set; }[IgnoreDataMember]public virtual ReservationState ReservationState { get; set; }