返回JSON這是我目前的Web API應該是默認
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")));
它工作正常,當我打電話API與這樣的查詢
for xml : http://localhost:49533/api/?type=xml
for json: http://localhost:49533/api/?type=json
,但我要的是JSON默認?那可能嗎?我想上面可供選擇,以及
它應該已經返回JSON默認情況下。 – har07
其默認返回xml – user570715
當我這樣請求 - http:// localhost:49533/api /產品我得到XML – user570715