c# - Self referencing loop detected (Solved 2-Ways)
Getting around C# self-referencing loop exception Sometimes we come across this kind of error when building web apps. This kind of error occurs when we have multiple navigational properties in the model and EF cannot parse the relational objects. The best way to overcome this is to use the Newtonsoft library to parse it to a string, use a DTO object or anonymous types to pass the data required or set this in the Global.asax file to ignore reference loop handling GlobalConfiguration . Configuration . Formatters . JsonFormatter . SerializerSettings . Re ferenceLoopHandling = ReferenceLoopHandling . Ignore ; The Model class If you have a product model class that has a navigational property Category, it would be hard for EF to parse the results of both properties to the view. Take a product class for example: public class Product{ public int Id { get; set; } public string Name{ get; set; } public decimal Price{ get; set; } ...