zoukankan      html  css  js  c++  java
  • asp.net mvc移除X-AspNet-Version、X-AspNetMvc-Version、Server

    asp.net mvc程序部署到IIS,,返回的HTTP头中包含Server, X-Powered-By, 和 X-AspNet-Version、X-AspNet-Version信息. 这些信息有时给攻击者找寻你的站点漏洞提供的依据.

    如下图所示:

    1.移除X-AspNet-Version

    在webconfig中做如下配置:

    2.移除X-AspNetMvc-Version

    在Global.asax中做如下配置

     3.移除Server

    3.1自定义server处理模型:

    //移除http相应中的server Server: Microsoft-IIS/10.
        public class CustomHeaderModule : IHttpModule
        {
            public void Init(HttpApplication context)
            {
                context.PreSendRequestHeaders += OnPreSendRequestHeaders;
            }
            public void Dispose()
            {
                throw new NotImplementedException();
            }
            void OnPreSendRequestHeaders(object sender, EventArgs e)
            {
                //HttpContext.Current.Response.Headers.Remove("Server");
                // 你可以在此设置
                HttpContext.Current.Response.Headers.Remove("Server");
            }
    
        }

    3.2在webconfig中做如下配置:

    <add name="CustomHeaderModule" type="EUQ.Boss.App_Start.CustomHeaderModule" />

    4.移除X-Powered-By: ASP.NET

     打开IIS管理器,定位到当前站点,找到HTTP响应标头

    删除节点:

    如上操作相当于在webconfig中做如下配置:

     <httpProtocol>
                <customHeaders>
                    <remove name="X-Powered-By" />
                </customHeaders>
            </httpProtocol>

  • 相关阅读:
    作业2019.1.15
    面向对象
    Arrays类的常用方法
    堆和栈的区别
    吃货联盟订餐系统
    解决Navicat连接MySQL出现1251-Client does not support authentication protocol requested by server;
    k-进制数
    怎么用宝塔面板搭建一个网站?
    Win10启动修复无法修复你的电脑解决方法
    java HashMap怎么用
  • 原文地址:https://www.cnblogs.com/eggTwo/p/11993340.html
Copyright © 2011-2022 走看看