I have this action:
public IHttpActionResult SearchFor(int aboItemType, DTO.FilterColumns filter)
{
//Do stuff...
return Ok<DataSet>(ds);
}
My client does:
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);
}
The above scenario works perfectly. However, if I comment the Accept line, the action returns the dataset in json format.
I would like to force this one particular action to always send the result in xml. Is this possible? Maybe with an attribute?
I used Сonfiguration.Formatters.XmlFormatter
public IHttpActionResult Get()
{
...
return Content(HttpStatusCode.OK, Model, Configuration.Formatters.XmlFormatter);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With