In ASP.NET MVC5 I have a controller with a JsonResult
return type.
Depending on parameters I want to return a 404, as this is descriptive of the user requesting non-existent data.
I could throw new HttpException(404, "message")
but this feels dirty given the return HttpNotFound()
syntax. This doesn't work, of course, because HttpNotFoundResult
does not inherit JsonResult
How should I cleanly return 404's from JsonResult
controller methods?
object
. – Menstruation