Appends a new header to the HTTP response.
- name
- The name of the HTTP header.
- value
- The value for the header.
This method will add the given header and value to the HTTP response when the headers are sent.If this routine is invoked after the headers have been sent to the client (for example if HttpResponse.Flush() has been called or Buffering is off and output has been written) this will throw a an System.Web.HttpException.
A number of headers are handled specially by this routine, these are:
- "Content-Length": the value in the header must be an integer that can be parsed by Int32.Parse or an exception will be thrown. Setting this header manually will force the size of the buffer to be at most the size specified. Any further output will be ignored. This will also have the side effect of disabling "chunked" transfers for HTTP 1.1 clients.
- "Content-Type": The value will not be appended, but only a single copy of this header will be sent on the reply.
- "Transfer-Encoding": Setting this value will disable chunked transfers.
- "Cache-Control": This header will only be sent once, and it defaults to private. You can use this to work around the limitation in the HttpResponse.CacheControl property.
If a header is appended various times the response output will contain multiple instances of the header. For example:
Will produce the following on the HTTP response:C# Example
Response.AppendHeader ("MyHeader", "A"); Response.AppendHeader ("MyHeader", "B");HTTP traffic Example
MyHeader: A MyHeader: B
Namespace: System.Web
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0