title: How to return custom 404 response when id not found
body: <p>I always wonder what is the best error response code in folowing situation:</p>
  
  <pre><code>public IActionResult Index(Guid id)
  {
      var entity = _dbContext.Entities.Find(id);
   
      if (entity == null)
      {
           return NotFound(); //??
      }
      return View(entity)
  }
  </code></pre>
  
  <p>404 - Not Found seems most appropriate, however, from debugging point of view, non-existing ID and wrong controller/action names are very different errors.</p>
  
  <p>Anyway, I've decided to return custom error page with more explanatory message, so I can differentiate between 404 and 404.</p>
  
  <p><strong>How to return custom 404 page from Controller's Action and default 404 in other cases?</strong></p>
  
  <p>I would like to avoid returning HttpResponseMessage, since I would need to change return type of the Action.</p>
  
  <p><em>PS: In comments you may vote for 404 resp other response code you would use in this particular case.</em></p>