title: Adding an Attribute for Response processing
body: <p>Using C#, Net Core 3.1</p>
  <p>I am wondering if someone can kindly help.
  I would like to add &quot;middleware&quot; but I think an Attribute is needed for my requirements as I want to do this selectively on specific API Actions only.
  How can I do some process (such as Signing a message and add it the response header) on a Response just before it is sent to the requesting client?</p>
  <p>For example</p>
  <pre><code>    [HttpGet]
      [PostResponseProcessAttribute]
      public IActionResult GetFoo(int id) {
          return MyFoo();
      }
  </code></pre>
  <p>So for this GetFoo Action, I would like to do something like this:</p>
  <pre><code>public class PostResponseProcessAttribute : Attribute {
      public OnBeforeSendingResponse(){
        var response = Response.Content.ReadAsStringAsync;
       //do some stuff
        response.Headers.Add(results from stuff)
      }
  }
  </code></pre>
  <p>Is it an Attribute that I need to implement and what is the function that I need override please?
  Also, a key bit is that Response is in the format and state that would be sent to to the client (i.e. passed other formatting middleware processing etc.) - this is important for Signing because any discrepancies would mean the client is verifying a response of a different version and therefore always fail.</p>
  <p>Thanks</p>