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>

  • 相关阅读:
    python基础之列表的坑
    python基础之字典篇
    坦克大战[源码] 你懂得
    java例程练习(键盘事件)
    android基础(对话框风格Activity实现)
    android基础(Activity)
    android基础(开发环境搭建)
    android基础(android程序的后台运行问题)
    java(敲 七)
    java例程练习(匿名类用法)
  • 原文地址:https://www.cnblogs.com/eggTwo/p/11993340.html
Copyright © 2011-2022 走看看