Skip to content

Instantly share code, notes, and snippets.

@RhysC
Created April 28, 2014 04:54
Show Gist options
  • Save RhysC/11362100 to your computer and use it in GitHub Desktop.
Save RhysC/11362100 to your computer and use it in GitHub Desktop.
asafaweb Excessive headers fixes
//On start up :
MvcHandler.DisableMvcResponseHeader = true;
// as an http module/global asax
protected void Application_PreSendRequestHeaders(object sender, EventArgs e)
{
// Remove the "Server" HTTP Header from response - security review recommends against sending this
var app = sender as HttpApplication;
if (app == null || null == app.Context) return;
var headers = app.Context.Response.Headers;
headers.Remove("Server");
}
<system.web>
<httpRuntime enableVersionHeader="false" />
...
<system.webServer>
<httpProtocol>
<customHeaders>
<!-- as recommended by secuirty audit-->
<remove name="X-Powered-By" />
</customHeaders>
</httpProtocol>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment