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/
Answers here are missing a little developer story problem. The ApiController class is still exposing a NotFound() method that developers may use. This would cause some 404 response to contain a uncontrolled result body.
I present here a few parts of code "better ApiController NotFound method" that will provide a less error-prone method that does not require developers to know "the better way of sending a 404".
ApiController called ApiController
NotFound method to let devs use the first available api[Obsolete("Use overload instead")]protected NotFoundResult NotFound(string message) that you want to encourageNegotiatedContentResult. see attached better NotFoundResult class.