Is there any way to hide / remove those unnecessary headers?

Headers to be removed:

Server
X-Powered-By
X-AspNet-Version

I have found a way to remove the Server header but I still cant find how to remove the other headers programmatically (i.e. as a servicestack plugin or something).

Thanks
Yannis

1 Like

To remove X-AspNet-Version you need to add enableVersionHeader="false" attribute to httpRuntime element in system.web section of web.config

    <system.web>
        <httpRuntime targetFramework="4.5"  enableVersionHeader="false" />
    </system.web>

To remove X-Powered-By add this to web.config:

    <system.webServer>
    
      <httpProtocol>
        <customHeaders>
          <clear />
          <remove name="X-Powered-By" />
        </customHeaders>
      </httpProtocol>
    
    </system.webServer>
2 Likes

since i hate xml configs:

using ServiceStack;

namespace My.Project.API.Plugins
{
    public class RemoveServicestackAddsFeature : IPlugin
    {
        public void Register(IAppHost appHost)
        {
            appHost.Config.GlobalResponseHeaders.Remove("X-Powered-By");
        }
    }
}
4 Likes