我有这个动作:
public IHttpActionResult SearchFor(int aboItemType, DTO.FilterColumns filter)
{
//Do stuff...
return Ok<DataSet>(ds);
}
我的客户这样做:
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/xml"));
var response = client.PostAsJsonAsync(myurl).Result;
if (response.IsSuccessStatusCode)
{
var results = HttpUtility.HtmlDecode(response.Content.ReadAsStringAsync().Result);
}
上述场景完美运行。但是,如果我注释 Accept 行,该操作将返回 json 格式的数据集。
我想强制这一特定操作始终以 xml 形式发送结果。这可能吗?也许有一个属性?
I used Сonfiguration.Formatters.XmlFormatter
public IHttpActionResult Get()
{
...
return Content(HttpStatusCode.OK, Model, Configuration.Formatters.XmlFormatter);
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)