.NET Web API

// 只返回json字符串,屏蔽自动选择xml格式的可能性,同时去掉讨厌的$id

var json = config.Formatters.JsonFormatter;

json.SerializerSettings.PreserveReferencesHandling = Newtonsoft.Json.PreserveReferencesHandling.None;

 

config.Formatters.Remove(config.Formatters.XmlFormatter);

原文地址:https://www.cnblogs.com/ilovewindy/p/4508872.html