ASP.Net Core Error JSON
<p>I'm playing a bit with ASP.NET Core. I'm creating a basic webapi.
I'd like to show a JSON error when there is a problem.</p>

<p>The printscreen shows want I want on my screen.
The only problem is that it's send with a statuscode of 200.</p>

<p><a href="https://i.stack.imgur.com/WG3Lh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WG3Lh.png" alt="PrintScreen"></a></p>

<pre><code>catch (NullReferenceException e)
{
    return Json(NotFound(e.Message));
}
</code></pre>

<p>I could solve it by doing this:</p>

<pre><code>return NotFound(new JsonResult(e.Message) {StatusCode = 404);
</code></pre>

<p>But I don't like this because now you can specify statuscode 500 with a NotFound.</p>

<p>Can someone put me in the correct direction?</p>

<p>Sincerely,
Brecht</p>