問題記錄
Self referencing loop detected for property 'ParentClassify' with type 'System.Data.Entity.DynamicProxies.Classify_A1F38FCCD6F018E5AEE129BF1636404F78C4F0F625B17FCC6A9B5AFDC8A5E1BF'. Path '[2].ChildrenClassifys[0]'.
描述:
自我引用循環探測到類型ParentClassify System.Data.Entity.DynamicProxies.Classify_A1F38FCCD6F018E5AEE129BF1636404F78C4F0F625B17FCC6A9B5AFDC8A5E1BF”型。路徑”[2].ChildrenClassifys[0]”。
解決辦法:
JsonSerializerSettings settings = new JsonSerializerSettings();
settings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
ViewBag.ClassifyJsonStr = JsonConvert.SerializeObject(classifylist, settings);