How to delete IIS custom headers like X-Powered-By: ASP.NET from response?

后端 未结 7 1657
小鲜肉
小鲜肉 2021-02-01 13:19

In IIS 7.0 integrated mode after deleting all headers with Response.ClearHeaders() IIS would add some other headers like Server

7条回答
  •  日久生厌
    2021-02-01 13:45

    Would like to add here that for the ASP.NET Core versions where there is no longer a web.config file a different approach is necessary.

    I made the following adjustments to remove the headers in ASP.NET Core 2.1:

    You can remove the x-powered-by header by replacing

    
            
            
    
    

    with

    
            
    
    

    in the applicationhost.config file found in the .vs\config folder of the project.

    The server header can be removed by adding

    .UseKestrel(c => c.AddServerHeader = false)
    

    in the Program.cs file.

提交回复
热议问题