title: How do i throw HttpResponseException(NotFound) using AspNetCore
body: <p>I had method written in <code>.Net 4.5</code>
  It is very simple. It either <code>returns Student entity or throw NOT FOUND exception.</code></p>
  
  <p>I am struggling to <code>port it into .NET Core 2.0.</code>
  As per my understanding, <code>.net core</code> recommend to to return <code>IActionResult</code>so , i can simply return <code>NotFound().</code> </p>
  
  <blockquote>
    <p>However, i am not sure how do i throw an not HttpResponseException (Not Found) exception .</p>
  </blockquote>
  
  <p>Method:</p>
  
  <pre><code>public Student Get(Guid id)
  {
      Student student = _studentSvc.Get(id);
      if (student != null)
          return student;
      else
          throw new HttpResponseException(HttpStatusCode.NotFound);
  }
  </code></pre>
  
  <p>Attempt:</p>
  
  <pre><code>public Student Get(Guid id)
  {
      Student student = _svc.Get(id);
      if (student != null)
          return student;
      else
          return NotFound();
  }
  </code></pre>
  
  <p>And if i try like following, then this line <code>return student</code> complains that can't implicitly convert student into <code>...Mvc.IActionResult</code> something</p>
  
  <pre><code>public IActionResult Get(Guid id)
  {
      Student student = _svc.Get(id);
      if (student != null)
          return student;
      else
          return NotFound();
  }
  </code></pre>
  
  <p>But it gives error can not convert NotFoundResult to Student !!</p>