Tips:
- One can adapt
HttpResponseMessage
toIHttpActionResult
usingResponseMessage
- Refer to my code below on how to send JSON responses using
HttpResponseMessage
andResponseMessage
- Also in some cases look into using the StringContent class.
References:
- http://stackoverflow.com/questions/21758615/why-should-i-use-ihttpactionresult-instead-of-httpresponsemessage
- http://stackoverflow.com/questions/28588652/web-api-2-return-content-with-ihttpactionresult-for-non-ok-response
- http://www.strathweb.com/2013/06/ihttpactionresult-new-way-of-creating-responses-in-asp-net-web-api-2/
- http://www.strathweb.com/2014/09/things-didnt-know-action-return-types-asp-net-web-api/
- http://bitoftech.net/2014/03/05/new-asp-net-web-api-2-ihttpactionresult-cors-tutorial/
Code: