Add the below code app_start
event in global.asax
file. In API Url add the query string:
GlobalConfiguration.Configuration.Formatters.JsonFormatter.MediaTypeMappings.Add(
new QueryStringMapping("type", "json", new MediaTypeHeaderValue("application/json")));
GlobalConfiguration.Configuration.Formatters.XmlFormatter.MediaTypeMappings.Add(
new QueryStringMapping("type", "xml", new MediaTypeHeaderValue("application/xml")));
e.g.:
for xml : http://localhost:49533/api/?type=xml
for json: http://localhost:49533/api/?type=json
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…