2016-02-29 39 views
-1

ASP.NET Web API 2,我能夠在本地機器上獲得JSON結果,但是當我在服務器上傳相同的項目時,它只返回XML結果。請爲此提出任何解決方案。如何使用ASP.NET Web API獲取JSON結果?

+0

您的客戶如何請求結果?你是否設置了正確的內容類型並接受標題? – Mithrandir

+0

我已經寫了config.Formatters.JsonFormatter.SupportedMediaTypes.Add( new MediaTypeWithQualityHeaderValue(「text/html」) );在WebApiConfig.cs –

+0

檢查此[SO鏈接](http://stackoverflow.com/questions/9847564/how-do-i-get-asp-net-web-api-to-return-json-instead-of- xml-using-chrome) –

回答

0

我通過將內容類型更改爲應用程序/ json來解決此問題

相關問題