title: Unable to set HTTP header in asp.net core for the SPA files
body: <p>Looking to set HTTP headers when serving files that are part of a SPA application in ASP.Net core 2.2 when running from the command line directly (using Kestrel).</p>
  
  <p>Following the instructions at <a href="https://github.com/aspnet/AspNetCore/issues/3147#issuecomment-435617378" rel="nofollow noreferrer">https://github.com/aspnet/AspNetCore/issues/3147#issuecomment-435617378</a>, I can't get the <code>StaticFileOptions.OnPrepareResponse</code> events firing at all. Headers don't get set, and even breakpoints don't get triggered.</p>
  
  <p><code>Statup.Configure()</code> looks like this:</p>
  
  <pre class="lang-cs prettyprint-override"><code>public void Configure(IApplicationBuilder app, IHostingEnvironment env)
  {
      if (env.IsDevelopment())
      {
          app.UseDeveloperExceptionPage();
      }
      else
      {
          app.UseExceptionHandler("/Error");
      }
  
      app.UseStaticFiles();
      app.UseSpaStaticFiles(new StaticFileOptions
      {
          OnPrepareResponse = ctx =&gt;
          {
              ctx.Context.Response.Headers.Add("Hello", "World"); // Never triggers
          }
      });
  
      app.UseMvc(routes =&gt;
      {
          routes.MapRoute(
              name: "default",
              template: "{controller}/{action=Index}/{id?}");
      });
  
      app.UseSpa(spa =&gt;
      {
          spa.Options.SourcePath = "ClientApp";
          spa.Options.DefaultPageStaticFileOptions = new StaticFileOptions
          {
              OnPrepareResponse = ctx =&gt;
              {
                  ctx.Context.Response.Headers.Add("Hello", "World"); // Never triggers
              }
          };
  
          if (env.IsDevelopment())
          {
              spa.UseAngularCliServer(npmScript: "start");
          }
      });
  }
  </code></pre>