问题
disable response headers and server details in c# web services
not able to find out the solution . please anyone can help how to remove response headers and disable iis details and x-powered-by in C# asp.net
回答1:
You achieve this by making use of web.config
file.
To remove the server use PreSendRequestHeaders
event and do
Response.Headers.Remove("Server");
Or change the server name
Response.Headers.Set("Server","FooServer");
The above will be achieved in the Global.asax.cs
The below will remove X-AspNet-Version
<system.web>
<httpRuntime enableVersionHeader="false" />
</system.web>
To remove X-Powered-By
use
<system.webServer>
<httpProtocol>
<customHeaders>
<remove name="X-Powered-By"/>
</customHeaders>
</httpProtocol>
</system.webServer>
Further reading here
来源:https://stackoverflow.com/questions/33913198/disable-response-headers-in-asp-net