Remove ASP.Net and IIS headers from HTTP response

7/17/2014 12:57:40 PM

There are 4 headers that should be removed.

Global.asax

protected void Application_Start(object sender, EventArgs e)
{
    MvcHandler.DisableMvcResponseHeader = true;
}

protected void Application_PresendRequestHeaders(object sender, EventArgs e)
{
    HttpContext.Current.Response.Headers.Remove("Server");
}

Web.Config

<system.web>
  <compilation debug="true" targetFramework="4.5" />
  <httpRuntime targetFramework="4.5" enableVersionHeader="false"/>
</system.web>

<system.webServer>
  <httpProtocol>
    <customHeaders>
      <remove name="X-Powered-By" />
    </customHeaders>
  </httpProtocol>
</system.webServer>