title: Changing the response object from OWIN Middleware
body: <p>My OWIN middleware is like this. (Framework is ASP.NET Web API).</p>
  
  <pre><code>public class MyMiddleware : OwinMiddleware
  {
      public MyMiddleware(OwinMiddleware next) : base(next) { }
  
      public override async Task Invoke(OwinRequest request, OwinResponse response)
      {
          var header = request.GetHeader("X-Whatever-Header");
  
          await Next.Invoke(request, response);
  
          response.SetHeader("X-MyResponse-Header", "Some Value");
          response.StatusCode = 403;
  
      }
  }
  </code></pre>
  
  <p>Questions:</p>
  
  <ol>
  <li><p>Is it the recommended practice to derive from <code>OwinMiddleware</code>? I see that in Katana source, some of the middleware classes derive from <code>OwinMiddleware</code> and some do not.</p></li>
  <li><p>I can see the request headers okay. Setting response header or status code after <code>Next.Invoke</code> in my middleware has no effect on the response returned to the client. But if I set the response header or status before the <code>Next.Invoke</code> call, the response with headers and the status that I set is returned to the client. What is the right way of setting these?</p></li>
  </ol>