MVC api  json 格式

 输出json

           var formatters = config.Formatters.Where(formatter =>
                   formatter.SupportedMediaTypes.Where(media =>
                   media.MediaType.ToString() == "application/xml" || media.MediaType.ToString() == "text/html").Count() > 0) 

//找到请求头信息中的介质类型 .ToList(); foreach (var match in formatters) { config.Formatters.Remove(match); //移除请求头信息中的XML格式 }

 

输出xml  

   在globle 中加入。。

GlobalConfiguration.Configuration.Formatters.XmlFormatter.UseXmlSerializer = true;

 

C# json 写法

MVC api  json 格式

相关文章:

  • 2022-12-23
  • 2021-11-16
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-18
  • 2021-11-11
猜你喜欢
  • 2022-12-23
  • 2022-02-09
  • 2022-12-23
  • 2022-12-23
  • 2021-12-06
  • 2022-12-23
相关资源
相似解决方案