How to remove ASP.Net MVC Default HTTP Headers?

前端 未结 11 2188
自闭症患者
自闭症患者 2020-11-28 01:23

Each page in an MVC application I\'m working with sets these HTTP headers in responses:

X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
X-AspNetMvc-Version         


        
11条回答
  •  渐次进展
    2020-11-28 01:37

    As described in Cloaking your ASP.NET MVC Web Application on IIS 7, you can turn off the X-AspNet-Version header by applying the following configuration section to your web.config:

     
       
    
    

    and remove the X-AspNetMvc-Version header by altering your Global.asax.cs as follows:

    protected void Application_Start() 
    { 
        MvcHandler.DisableMvcResponseHeader = true; 
    }
    

    As described in Custom Headers You can remove the "X-Powered-By" header by applying the following configuration section to your web.config:

    
       
          
             
          
       
    
    

    There is no easy way to remove the "Server" response header via configuration, but you can implement an HttpModule to remove specific HTTP Headers as described in Cloaking your ASP.NET MVC Web Application on IIS 7 and in how-to-remove-server-x-aspnet-version-x-aspnetmvc-version-and-x-powered-by-from-the-response-header-in-iis7.

提交回复
热议问题