How to delete IIS custom headers like X-Powered-By: ASP.NET from response?

后端 未结 7 1654
小鲜肉
小鲜肉 2021-02-01 13:19

In IIS 7.0 integrated mode after deleting all headers with Response.ClearHeaders() IIS would add some other headers like Server

相关标签:
7条回答
  • 2021-02-01 14:05

    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.

    0 讨论(0)
提交回复
热议问题