I understand that WEB API uses content negotiation for Accept - Content-Type to return json or xml. This is not good enough and I need to be able pragmatically decide if I want to return json or xml.
The internet is flooded with obsolete examples of using HttpResponseMessage<T>, which is no longer present in MVC 4.
tokenResponse response = new tokenResponse();
response.something = "gfhgfh";
if(json)
{
return Request.CreateResponse(HttpStatusCode.OK, response, "application/json");
}
else
{
return Request.CreateResponse(HttpStatusCode.OK, response, "application/xml");
}
How do I change the above code so that it works?