title: ASP.NET Core equivalent of ASP.NET MVC 5's HttpException
body: <p>In ASP.NET MVC 5 you could throw a <a href="https://docs.microsoft.com/en-us/dotnet/api/system.web.httpexception" rel="noreferrer">HttpException</a> with a HTTP code and this would set the response like so:</p>
  
  <pre><code>throw new HttpException((int)HttpStatusCode.BadRequest, "Bad Request.");
  </code></pre>
  
  <p><code>HttpException</code> does not exist in ASP.NET Core. What is the equivalent code?</p>