.NET MVC 4 を使用して C# で実装されている Web サービスがありますが、Accept: application/json ヘッダーを送信しているにもかかわらず、何らかの理由で常に XML 形式でデータが返されます。何が間違っている可能性がありますか?
前もって感謝します
更新:コントローラーコードは次のようになります
public HttpResponseMessage GetData()
{
...
DashboardInformation d = new DashboardInformation()
{
Name = "Test",
employees = employees,
shortcuts = shortcuts,
notes = dashboardNoteList,
timeEntries = dashboardTimeList,
timeTracker = timeTracker,
timeTrackerFromDate = ToUnixTimestamp(fromDate),
timeTrackerToDate = ToUnixTimestamp(toDate),
timeSummary = timeSummary,
userInfo = uInfo
};
return Request.CreateResponse(HttpStatusCode.OK, d);
}
更新 2 : 生のリクエストとレスポンス
リクエスト
GET /RestService/api/Dashboard/GetData HTTP/1.1
Host: xxx
Connection: keep-alive
Cache-Control: max-age=0
X-Requested-With: XMLHttpRequest
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.94 Safari/537.4
Accept: application/json, text/javascript, */*; q=0.01
Referer: http://xxx/Firm4.0/dashboard.html
Accept-Encoding: gzip,deflate,sdch
Accept-Language: es-ES,es;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
応答
HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Content-Type: application/xml; charset=utf-8
Expires: -1
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Tue, 06 Nov 2012 19:01:59 GMT
Content-Length: 3610
...