In one of my Get request, I want to return an HttpResponseMessage with some content. Currently I have it working as follows:
var header = new MediaTypeHeader
HttpResponseMessage
was removed after Beta. Right now, instead of a typed HttpResponseMessage
we have a typed ObjectContent
If you manually create HttpResponseMessage
using its default parameterless constructor, there is no request context available to perform content negotiation - that's why you need to specify the formatter, or perform content negotiation by hand.
I understand you don't want to do that - so use this instead:
HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, objInstance);
That would create the response message relying on the content negotiation performed against the request.
Finally, you can read more about content negotiation here On this link