问题记录
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);
settings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
ViewBag.ClassifyJsonStr = JsonConvert.SerializeObject(classifylist, settings);