Hardening ASP.NET Response Headers (Code)

A reliable way to harden your ASP.NET web application is to remove and skew the response headers via code. This will throw off automated scans that are performing banner grabbing in an attempt to identify vulnerabilities. There are ways to do this in IIS, however, performing this in code means it’s applied everywhere that the code is deployed. This may include UAT servers in the DMZ that could be exposed to external threats.

I learned this technique in an enterprise environment.

Setup

ASP.NET Web Application (.NET Framework 4.5.2)

Global.asax

Http Module

web.config

Verifying