New Web API 2.0 project so we have full control over the entire request / response pipeline.
How do we remove the "X-" headers from a response sent by ASP.NET Web API response? Specifically, at the moment and always subject to change, we want to remove "X-AspNet-Version
", "X-Powered-By
", and "X-SourceFiles
".
We tried result.Headers.Remove("X-AspNet-Version");
before returning the HttpResponseMessage
from the controller. That didn't work as the headers still appeared in Fiddler. I also didn't find any headers anywhere on the HttpResponseMessage
object. To me, this indicated I may need to dig deeper into the pipeline but I'm not sure where to start or if that's correct.