在WebApiConfig.cs文件中添加以下代码:
config.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;
该代码用于忽略Json序列化中的循环引用,提高性能并减少加载时间。此外,还可以进行优化调整,如使用Response Compression来压缩输出内容。
上一篇:asp.netwebapi向vue.js返回响应数据为undefined
下一篇:ASP.NETWebApi异常时返回不同的对象