title: Return 404 page without redirect
body: <p>I'm trying to get my 404s working correctly but can't figure out how to get it quite right.</p>
  
  <p>Initially I set my the following in my Statup Configure method:</p>
  
  <pre class="lang-cs prettyprint-override"><code>app.UseMvc(routes =&gt;
  {
      // routing here
  });
  
  app.Use((context, next) =&gt;
  {
      context.Response.StatusCode = 404;
      return next();
  });
  
  app.UseStatusCodePagesWithRedirects("/error/{0}");
  </code></pre>
  
  <p>Which redirected to a page where I showed the error. However the status codes were <code>302 &gt; 200</code>. I set the <code>/error/{code}</code> action to return the relevant status code, so now I have <code>302 &gt; 404</code> which (due to the 302 redirect) makes it look as though the <code>/error/404</code> page doesn't exist (which it does).</p>
  
  <p>What I want to do is to return the error page without the redirect, so that attempting to request <code>/doesntexist</code> will return 404 and display the error page.</p>
  
  <p>The other thing I tried is to use <code>app.UseStatusCodePagesWithReExecute("/error/{0}");</code> which does return a 404 without changing the url but displays only a blank page rather than my error page</p>