If I have an async
web API method, then the Request
object is null (as id discussed in other posts such as this one).
It seems that the most common means of returning a response in this circumstance is to use something like
return new HttpResponseMessage(HttpStatusCode.OK) {
Content = new ObjectContent<T>(myObj, new JsonMediaTypeFormatter())
};
But whatabout the formatting? Normally the Request
object handles that because it knows what was requested, but if I don't have a Request
object then how do I know the requested format?webapi