Accept
以下の単純な Action メソッドは、ヘッダーが に設定されているかどうかに関係なく、常に JSON を返しますapplication/xml
。コンテンツ ネゴシエーションは、この同じコントローラーにある他のアクションでも正常に機能します。
public HttpResponseMessage GetOrder(int id) {
var orderDescription = mydbc.tbl_job_versions.AsNoTracking().Where(t => t.JobId == id)
.Select(t => new{Id = t.JobId, Description = t.Brand + " " + t.Variety + " " + t.Promotion + " " + t.MarketSegment }).FirstOrDefault ();
if (orderDescription == null) {
return new HttpResponseMessage(HttpStatusCode.NotFound);
}
else {
return Request.CreateResponse((HttpStatusCode)200, orderDescription);
}
}
これがコンテンツ ネゴシエーションを実行せず、代わりに常に JSON を返す原因は何ですか?