title: JsonException: A possible object cycle was detected which is not supported. This can either be due to a cycle or if the object depth is larger than
body: <p>In my web API when I run project to get data from the database got this error
  .net core 3.1</p>
  <blockquote>
  <p>JsonException: A possible object cycle was detected which is not supported. This can either be due to a cycle or if the object depth is larger than the maximum allowed depth of 32.</p>
  </blockquote>
  <p>These are my codes:</p>
  <p>my Model</p>
  <pre><code>public class Product
  {
      public int Id { get; set; }
      public string Name { get; set; }
      public string ProductText { get; set; }
      public int ProductCategoryId { get; set; }
      [JsonIgnore]
      public virtual ProductCategory ProductCategory { get; set; }
  }
  </code></pre>
  <p>my productCategory class is:</p>
  <pre><code>public class ProductCategory
  {
      public int Id { get; set; }
      public string Name { get; set; }
      public string CatText { get; set; }
      public string ImagePath { get; set; }
      public int Priority { get; set; }
      public int Viewd { get; set; }
      public string Description { get; set; }
      public bool Active { get; set; }
      public DateTime CreateDate { get; set; }
      public DateTime ModifyDate { get; set; }
      public virtual ICollection&lt;Product&gt; Products { get; set; }
  }
  </code></pre>
  <p>my repo is</p>
  <pre><code>public async Task&lt;IList&lt;Product&gt;&gt; GetAllProductAsync()
      {
          return await  _context.Products.Include(p =&gt; p.ProductCategory).ToListAsync(); 
      }
  </code></pre>
  <p>my interface</p>
  <pre><code>public interface IProductRepository
  {
     ...
     Task&lt;IList&lt;Product&gt;&gt; GetAllProductAsync();
     ...
  }
  </code></pre>
  <p>and this is my controller in api project</p>
  <pre><code>[Route(&quot;api/[controller]&quot;)]
  [ApiController]
  public class ProductsController : ControllerBase
  {
      private readonly IProductRepository _productRepository;
  
      public ProductsController(IProductRepository productRepository)
      {
          _productRepository = productRepository;
      }
      [HttpGet]
      public ActionResult Get()
      {
          return Ok(_productRepository.GetAllProduct());
      }
  }
  </code></pre>
  <p>When I run API project and put this URL: https://localhost:44397/api/products
  I got that error,
  I can't resolve it</p>