Chaps, after some doodling around I see I can get the Accept values
straight out of the Request in the controller's code. That does now seem to
be the logical way of choosing the response format.

More confusion though ... I tried to write a controller method that
returned either plain text or XML, but the samples I've found return
different types. One does this:

public HttpActionResult Sample1()
return Ok("hello");

public HttpResponseMessage Sample2()
return new HttpResponseMessage() { Content = new StringContent("hello") };






On 20 January 2014 13:12, Dave Walker <rangitat...@gmail.com> wrote:

> Accept header is the norm
>
> On 20 January 2014 15:03, Greg Keogh <g...@mira.net> wrote:
>
>> Folks, what is the recommended way of letting the caller choose the
>> format of the response? I have a method that can return plain text or XML,
>> so how does the caller choose the one they want?
>>
>> I could have a &format= parameter on the method call (Rackspace do that),
>> or is it better to inspect the Accept header and obey it? Or something else?
>>
>> Greg K
>>
>
>

Reply via email to