In IIS 10, we use a similar solution to Drew's approach, i.e.:
using System;
using System.Web;
namespace Common.Web.Modules.Http
{
/// <summary>
/// Sets custom headers in all requests (e.g. "Server" header) or simply remove some.
/// </summary>
public class CustomHeaderModule : IHttpModule
{
public void Init(HttpApplication context)
{
context.PreSendRequestHeaders += OnPreSendRequestHeaders;
}
public void Dispose() { }
/// <summary>
/// Event handler that implements the desired behavior for the PreSendRequestHeaders event,
/// that occurs just before ASP.NET sends HTTP headers to the client.
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void OnPreSendRequestHeaders(object sender, EventArgs e)
{
//HttpContext.Current.Response.Headers.Remove("Server");
HttpContext.Current.Response.Headers.Set("Server", "MyServer");
}
}
}
And obviously add a reference to that dll in your project(s) and also the module in the config(s) you want:
<system.webServer>_x000D_
<modules>_x000D_
<!--Use http module to remove/customize IIS "Server" header-->_x000D_
<add name="CustomHeaderModule" type="Common.Web.Modules.Http.CustomHeaderModule" />_x000D_
</modules>_x000D_
</system.webServer>
_x000D_
IMPORTANT NOTE1: This solution needs an application pool set as integrated;
IMPORTANT NOTE2: All responses within the web app will be affected by this (css and js included);