ApiController默认使用Json格式

WebApiConfig

GlobalConfiguration.Configuration.Formatters.XmlFormatter.SupportedMediaTypes.Clear();
GlobalConfiguration.Configuration.Formatters.JsonFormatter.MediaTypeMappings.Add(new QueryStringMapping("datatype", "json", "application/json"));
 
可以在浏览器直接访问时输出json内容,而不是xml内容
posted @ 2017-11-17 23:53  太阳底下淋雨  阅读(621)  评论(0编辑  收藏  举报