using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace Sony.Filtr.Utility { // This class borrows from http://consultingblogs.emc.com/howardvanrooijen/archive/2009/08/25/cloaking-your-asp-net-mvc-web-application-on-iis-7.aspx // We want to get rid of all headers that could be used to fingerprint the server. public class CloakHttpHeadersModule : IHttpModule { private static readonly List HeadersToCloak; static CloakHttpHeadersModule() { HeadersToCloak = new List { "Server", "X-AspNet-Version", "X-AspNetMvc-Version", "X-Powered-By", }; } public void Init(HttpApplication context) { context.PreSendRequestHeaders += OnPreSendRequestHeaders; } private void OnPreSendRequestHeaders(object sender, EventArgs e) { HeadersToCloak.ForEach(h => HttpContext.Current.Response.Headers.Remove(h)); } public void Dispose() { } } }