title: Add a custom response header in ApiController
body: <p>Until now, I had a <code>GET</code> method that looked like the following:</p>
  
  <pre><code>protected override async Task&lt;IHttpActionResult&gt; GetAll(QueryData query)
  {
       // ... Some operations
  
       //LINQ Expression based on the query parameters
       Expression&lt;Func&lt;Entity, bool&gt;&gt; queryExpression = BuildQueryExpression(query);
  
       //Begin to count all the entities in the repository
       Task&lt;int&gt; countingEntities = repo.CountAsync(queryExpression);
  
       //Reads an entity that will be the page start
       Entity start = await repo.ReadAsync(query.Start);
  
       //Reads all the entities starting from the start entity
       IEnumerable&lt;Entity&gt; found = await repo.BrowseAllAsync(start, queryExpression);
  
       //Truncates to page size
       found = found.Take(query.Size);
  
       //Number of entities returned in response
       int count = found.Count();
  
       //Number of total entities (without pagination)
       int total = await countingEntities;
  
       return Ok(new {
            Total = total,
            Count = count,
            Last = count &gt; 0 ? GetEntityKey(found.Last()) : default(Key),
            Data = found.Select(e =&gt; IsResourceOwner(e) ? MapToOwnerDTO(e) : MapToDTO(e)).ToList()
       });
  }
  </code></pre>
  
  <p>This worked like a charm and it was good. However, I was told recently to send the response <strong>metadata</strong> (that is, <code>Total</code>, <code>Count</code> and <code>Last</code> properties) as response custom headers instead of the response body.</p>
  
  <p>I cannot manage to access the <code>Response</code> from the ApiController. I thought of a filter or attribute, but how would I get the metadata values?</p>
  
  <p>I can keep all this information on the response and then have a filter that will deserialize the response before being sent to the client, and create a new one with the headers, but that seems troublesome and bad.</p>
  
  <p>Is there a way to add custom headers directly from this method on an <code>ApiController</code>?</p>