0

I'm working on a .NET CORE Web API. In the model classes I have a bi-directional reference that upon request throws a Self Referencing Loop Detected error. These are the model classes:

public class Probleem 
{
public int Id { get; set; }
[Required]
public Gebruiker Gebruiker { get; set; }
[Required]
public DateTime TimeCreated { get; set; }
}
public class Gebruiker
{
public int Id { get; set; }
[Required]
public String Voornaam { get; set; }
[Required]
public String Naam { get; set; }
[Required]
public List<Probleem> Problemen { get; set; } = new List<Probleem>();
}

The request I am trying to make is a GET request of Probleem, but clearly the code doesn't realize both classes keep referencing each other, causing the crash. I have read that in order to fix this issue, i need to add code to the Global.asax.cs file, but I can't find the file nor create it in the New Item menu. global asax not found in add item

Antoinneke
  • 11
  • 2

1 Answers1

0

Apologies for being blind, but I totally misread this previous question: JSON.NET Error Self referencing loop detected for type The answer was actually in that question.

Antoinneke
  • 11
  • 2