(转) IIS隐藏响应头信息

先安装url-rewrite组件
http://www.iis.net/downloads/microsoft/url-rewrite
修改应用根目录下的Web.config配置文件
复制代码
<configuration>
...
  <system.webServer>
  ...
        <httpProtocol>
            <customHeaders>
                <remove name="X-Powered-By" />
            </customHeaders>
        </httpProtocol>
        <rewrite>    
          <outboundRules rewriteBeforeCache="true">
            <rule name="Remove Server header">
              <match serverVariable="RESPONSE_Server" pattern=".+" />
              <action type="Rewrite" value="Apache" />
            </rule>
          </outboundRules>
        </rewrite>
  </system.webServer>
</configuration>
复制代码

隐藏X-AspNet-Version

<configuration>
...
  <system.web>
    <compilation targetFramework="4.6.1" />
    <httpRuntime enableVersionHeader="false" />
    <!--httpRuntime targetFramework="4.6.1" maxRequestLength="40960" /-->
  </system.web>
</configuration>

 

删除X-AspNetMvc-Version

在Global.asax的Application_Start事件中将MvcHandler类的DisableMvcResponseHeader属性设置为True
MvcHandler.DisableMvcResponseHeader = True

 

删除X-Powered-By

IIS8中移除X-Powered-By HTTP头的步骤:

  1 打开IIS管理器
  2 展开 网站 选择对应的项目并双击 HTTP响应标头
  3 删除相应的头信息

 

转自:https://www.cnblogs.com/cpw6/p/15767703.html

参考内容:https://github.com/dionach/StripHeaders

 

posted @   Cong0ks  阅读(445)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· 单线程的Redis速度为什么快?
· 展开说说关于C#中ORM框架的用法!
· Pantheons:用 TypeScript 打造主流大模型对话的一站式集成库
历史上的今天:
2019-12-06 English Voice of <<Wish You Were Here>>
2018-12-06 English trip V1 - 9.Do you Ever Say Never? 你有没有说永远不会? Teacher:Lamb Key: Adverbs of frequency (频率副词)
2018-12-06 every day a practice —— morning(2)
点击右上角即可分享
微信分享提示