Web API: Content in HttpResponseMessage

HttpResponseMessage<T> 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<MyObject>(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

Leave a Comment

techhipbettruvabetnorabahisbahis forumu