title: Add custom header to all responses in Web API
body: <p>Simple question, and I am sure it has a simple answer but I can't find it.</p>
  
  <p>I am using WebAPI and I would like to send back a custom header to all responses (server date/time requested by a dev for syncing purposes).</p>
  
  <p>I am currently struggling to find a clear example of how, in one place (via the global.asax or another central location) I can get a custom header to appear for all responses.</p>
  
  <hr>
  
  <p>Answer accepted, here is my filter (pretty much the same) and the line i added to the Register function of the WebApi config.</p>
  
  <p><strong>NOTE: The DateTime stuff is NodaTime, no real reason just was interested in looking at it.</strong></p>
  
  <pre><code>    public override void OnActionExecuted(HttpActionExecutedContext actionExecutedContext)
      {
          actionExecutedContext.Response.Content.Headers.Add("ServerTime", Instant.FromDateTimeUtc(DateTime.Now.ToUniversalTime()).ToString());
      }
  </code></pre>
  
  <p>Config Line:</p>
  
  <pre><code>config.Filters.Add(new ServerTimeHeaderFilter());
  </code></pre>