相关疑难解决方法(0)

JsonException: 检测到不支持的可能的对象循环。这可能是由于循环或对象深度大于

在我的 web api 中,当我运行项目以从数据库获取数据时出现此错误 .net core 3.1

JsonException: 检测到不支持的可能的对象循环。这可能是由于循环或对象深度大于最大允许深度 32。

这些是我的代码我的模型

 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; }
}
Run Code Online (Sandbox Code Playgroud)

我的 productCategory 类是:

 public class ProductCategory
{
    public int Id { get; set; }
    public string Name { get; set; }
    public string CatText { get; set; …
Run Code Online (Sandbox Code Playgroud)

c# api asp.net-core-mvc asp.net-core

25
推荐指数
5
解决办法
3万
查看次数

标签 统计

api ×1

asp.net-core ×1

asp.net-core-mvc ×1

c# ×1