Remove Server Response Header IIS 8.0 / 8.5

前端 未结 8 1489
既然无缘
既然无缘 2020-12-23 20:57

How can we remove the server header response in IIS 8.0/8.5?
My current server report: Microsoft-IIS/8.0 Microsoft-IIS/8.5
For IIS 7.0 I

8条回答
  •  Happy的楠姐
    2020-12-23 21:33

    This is dead simple. Just create a custom module:

    public class HeaderStripModule : IHttpModule
    {
        public void Init(HttpApplication application)
        {
            application.PreSendRequestHeaders += (sender, args) => HttpContext.Current.Response.Headers.Remove("Server");
        }
    
        public void Dispose(){}
    }
    

    And then register in web.config or applicationHost.config if you want machine wide implementation.

    
      
          
      
    
    

提交回复
热议问题