Blog: How Tos

How to remove IIS server response header banners

consultant-placeholder04 Roger Jefferiss 29 Oct 2013

This snappy guide shows how to set-up a module to remove the server response header from IIS7 / IIS7.5 banners.

Doing this reduces the available information to an attacker.
It means there is less for them to fingerprint if they are scoping out your web services for vulnerabilities.

You can often find webserver information in public lookups, try out a few URLs for yourself here, other tools are available.

The first step is to create the code module that will broadcast a custom server response header of your choosing.
Create a new visual studio class Library project called CustomServerHeaderModule, then insert the following example code:

using System;
using System.Text;
using System.Web;

namespace CustomServerHeaderModule
public class CustomServerHeaderModule : IHttpModule
public void Init(HttpApplication context)
context.PreSendRequestHeaders += OnPreSendRequestHeaders;
public void Dispose()
{ }
void OnPreSendRequestHeaders(object sender, EventArgs e)
HttpContext.Current.Response.Headers.Set(“Server”, “EXAMPLE SERVER“);

To change the Server name just modify the red text.

Once you have added that example code, and that DLL is compiled the second step is to install it on the IIS server.

Copy the DLL to the bin directory in the root of the web server and then add the following to the web.config file:

<add name=”CustomServerHeader” type=”CustomServerHeaderModule.CustomServerHeaderModule” />


You’ll need to make sure that if you have sections already in the configuration file you just need to add the red text.

Done. Now recheck those banners.