Http 响应头中包含敏感信息解决办法

1.移除包含Server版本信息

在global.asax的Application_PreSendRequestHeaders方法中添加这个代码就可以,如下

           var app = sender as HttpApplication;
           if (app == null || app.Context == null)
           {
               return;
           }
 
           // 移除 Server
           app.Context.Response.Headers.Remove("Server");

  

2.移除包含X-AspNetMvc-Version的解决方法

在global.asax的Application_Start方法中添加这个代码就可以,如下

          MvcHandler.DisableMvcResponseHeader = true;

3.移除X-Powered-by

这个消息可以直接在IIS中处理:选择要处理的网站->在中间大区域内找到HTTP Response Headers->双击打开->在列表中找到X-Powered-By,继续双击打开,在弹出的小窗口中把Value值删除,点击OK就可以了。

4.移除X-AspNet-Version

在Web.config文件中<httpRuntime enableVersionHeader="false" />

posted @ 2022-07-19 17:17  VarForrest  阅读(529)  评论(0编辑  收藏  举报