Skip to content

Instantly share code, notes, and snippets.

@dax70
Created July 16, 2012 18:28
Show Gist options
  • Save dax70/3124173 to your computer and use it in GitHub Desktop.
Save dax70/3124173 to your computer and use it in GitHub Desktop.
Disabling Response Headers Code Centric
protected void Application_PreSendRequestHeaders(object sender, EventArgs e)
{
HttpContext.Current.Response.Headers.Remove("Server");
HttpContext.Current.Response.Headers.Remove("X-Powered-By"); // Disabled in config
HttpContext.Current.Response.Headers.Remove("X-AspNet-Version"); // Disabled in config
HttpContext.Current.Response.Headers.Remove("X-AspNetMvc-Version"); // Disabled on Application_Start
}
@dax70
Copy link
Author

dax70 commented Jul 16, 2012

Add the following to the Globals.asax or class that inherits from HttpApplication to remove Response Headers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment