title: .NET Core 2.2 vs 5.0 IActionResult "NotFound" Serialization
body: <p>In .NET Core 2.2 returning NotFound() in a WebAPI controller like this:</p>
  <pre><code>[HttpGet]
  public IActionResult DoSomething() {
    return NotFound(new IOException(&quot;Unable to locate specified resource.&quot;));
  }
  </code></pre>
  <p>would respond with a 404 status code with JSON in the body of the response like this:</p>
  <pre><code>{
     &quot;ClassName&quot;:&quot;System.Exception&quot;,
     &quot;Message&quot;:&quot;Unable to locate specified resource.&quot;,
     &quot;Data&quot;:null,
     &quot;InnerException&quot;:null,
     &quot;HelpURL&quot;:null,
     &quot;StackTraceString&quot;:&quot;Huge stack trace goes here...&quot;,
     &quot;RemoteStackTraceString&quot;:null,
     &quot;RemoteStackIndex&quot;:0,
     &quot;ExceptionMethod&quot;:null,
     &quot;HResult&quot;:-2146233088,
     &quot;Source&quot;:&quot;Namespace goes here...&quot;,
     &quot;WatsonBuckets&quot;:null
  }
  </code></pre>
  <p>However in .NET Core 5.0, the same exact code results in the following JSON:</p>
  <pre><code>{
     &quot;TargetSite&quot;:null,
     &quot;StackTrace&quot;:null,
     &quot;Message&quot;:&quot;Unable to locate specified resource.&quot;,
     &quot;Data&quot;:{
        
     },
     &quot;InnerException&quot;:null,
     &quot;HelpLink&quot;:null,
     &quot;Source&quot;:null,
     &quot;HResult&quot;:-2146232800
  }
  </code></pre>
  <p>Now apparently JSON serialization of an ObjectResult has changed between versions, but without throwing a real exception and manually serializing it with a separate error handler, is there a way to configure the serialization so NotFound() (or any other ObjectResult for that matter) will return the full exception object like it did previously?</p>