简体   繁体   中英

How to change the server response header in asp.net2.0 with IIS6.0 server

How to modify the server values of response header through code behind using asp.net 2.0 with IIS6.0 server.

I have tried Response.Headers.Set("XYZ","ABC"); But it displays throw integrated pipeline error.

Try this:

HttpResponse response = ...;
response.ClearHeaders(); 
response.ClearContent(); 
response.ContentType = "application/octet-stream"; 
response.AppendHeader("Content-Disposition", ""); //(write whatever headers you want like this)

I would use the below in Global.asax.cs to remove the Server header

protected void Application_PreSendRequestHeaders()
{
    Response.Headers.Remove("Server");
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM