In IIS 7.0
integrated mode
after deleting all headers with Response.ClearHeaders()
IIS would add some other headers like Server
You can use appcmd.exe (IIS 7 and above) to do your job. The script will be like this:
C:\Windows\System32\inetsrv\appcmd.exe set config -section:system.webserver/httpProtocol /-customHeaders.["name='X-Powered-By'"] /commit:apphost
/commit:apphost
: This commits the configuration settings to the appropriate location section in the ApplicationHost.config file.
I usually create a batch file of all these scripts which I run on the web server after the application is installed.
For ASP.NET MVC applications the approach is different and you can refer to other answers given here.