1

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.netenter image description here

1 Answer 1

3

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

Sign up to request clarification or add additional context in comments.

2 Comments

thanks.. not able to execute this one in my app.. Response.Headers.Remove("Server");
add above attached my snapshots.. error message is : This operation requires IIS integrated pipeline mode.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.