title: Why is StatusCode not set from Mvc when exception occurs
body: <p>In a simple application:</p>
  
  <pre><code>public void Configure(IApplicationBuilder app, IHostingEnvironment env)
  {
      app.Use(async (context, next) =&gt;
      {
          try
          {
              await next();
          }
          finally
          {
              var test = context.Response.StatusCode;
              //test=200 when exception is thrown from Mvc()
          }
      });
      app.UseMvc();
  }
  </code></pre>
  
  <p>Why is the <code>Response.StatusCode</code> not set if a controller throws an <code>Exception</code>? This seems quite surprising and undocumented. It seems to work inconsistent with the concept of the pipeline where eg. <strong>401</strong> and <strong>404</strong> have been set at this point. Is this a bug or is this by design?</p>