title: ASP.NET MVC: Programmatically set HTTP headers on static content
body: <p>I have an ASP.NET application with a filter wired up in <code>RegisterGlobalFilters</code> that performs the following:</p>
  
  <pre><code>public class XFrameOptionsAttribute : ActionFilterAttribute
  {
      public override void OnResultExecuting(System.Web.Mvc.ResultExecutingContext filterContext)
      {
          filterContext.HttpContext.Response.AddHeader("X-FRAME-OPTIONS", "SAMEORIGIN");
      }
  }
  </code></pre>
  
  <p>Looking in Fiddler, I can see that views returned from the webserver include this header.  Static files however, such as JavaScript do not include this header in the HTTP response.</p>
  
  <p>How do I get ASP.NET MVC to also apply this filter to any static files the web server returns?</p>