I am returning a NotFound IHttpActionResult
, when something is not found in my WebApi GET action. Along with this response, I want to send a custom message and/or the exception message (if any). The current ApiController
's NotFound()
method does not provide an overload to pass a message.
Is there any way of doing this? or I will have to write my own custom IHttpActionResult
?
Here's a one-liner for returning a IHttpActionResult NotFound with a simple message:
return Content(HttpStatusCode.NotFound, "Foo does not exist.");