我只是
App_Start / WebApiConfig.cs在我的MVC Web API 项目中的类中添加以下内容。
config.Formatters.JsonFormatter.SupportedMediaTypes .Add(new MediaTypeHeaderValue("text/html") );这样可以确保您在大多数查询中都获取JSON,但是
XML在发送时可以获取JSON
text/xml。
如果您需要回应
Content-Type,
application/json请查看下面的Todd回答。
NameSpace正在使用
System.Net.Http.Headers。



