Hidden ASP.NET MVC version information, so it does not show in the HTTP Header

Hidden ASP.NET MVC version information, it does not show in the HTTP Header.

First, hide: X-AspNetMvc-Version

Add in the Application_Start method in the Global.asax file:

MvcHandler.DisableMvcResponseHeader = true;

Second, remove the Server Header

Add in the Global.asax file:

 protected void Application_PreSendRequestHeaders(object sender, EventArgs e)
        {
            var app = sender as HttpApplication;
            if (app == null || app.Context == null)
            {
                return;
            }

            // 移除 Server
            app.Context.Response.Headers.Remove("Server");
        }

Third, remove the X-Powered-By

Add in the Web.config file:

<system.webServer> 
    <-! other content -> 
    <httpProtocol> 
        <customHeaders> 
            <-! By-remove X-Powered -> 
            <the Clear /> 
            <-! You can also add your own X-Powered -By identified as -> 
            <the Add name = "X--Powered-By" value = "bbb.com" /> 
        </ customHeaders> 
    </ httpProtocol> 
</system.webServer>

Fourth, remove the X-AspNet-Version

In Web.config file <httpRuntime enableVersionHeader = "false" />

<httpRuntime enableVersionHeader="false" />

Guess you like

Origin www.cnblogs.com/namexiaoqi/p/10981224.html