disable response headers in asp.net

雨燕双飞 提交于 2019-12-13 05:13:56

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!