HttpResponse.AppendHeader Method

Adds an HTTP header to the output stream.

Namespace:  System.Web
Assembly:  System.Web (in System.Web.dll)

public void AppendHeader(
	string name,
	string value
)

Parameters

name
Type: System.String
The name of the HTTP header to add to the output stream.
value
Type: System.String
The string to append to the header.

ExceptionCondition
HttpException

The header is appended after the HTTP headers have been sent.

If you use the AppendHeader method to send cache-specific headers and at the same time use the cache object model (Cache) to set cache policy, HTTP response headers that pertain to caching (Cache-Control, Expires, Last-Modified, Pragma, and Vary) might be deleted when the cache object model is used. This behavior enables ASP.NET to maintain the most restrictive settings. For example, consider a page that includes user controls. If those controls have conflicting cache policies, the most restrictive cache policy will be used. If one user control sets the header "Cache-Control: Public" and another user control sets the more restrictive header "Cache-Control: Private" via calls to SetCacheability, then the "Cache-Control: Private" header will be sent with the response.

For a list of standard HTTP/1.1 headers, see section 14, "Header Field Definitions," in the Hypertext Transfer Protocol -- HTTP/1.1 specification on the World Wide Web Consortium (W3C) Web site.

The following example calls the AppendHeader method to add a custom header to the HttpResponse object sent to the requesting client.


Response.AppendHeader("CustomAspNetHeader", "Value1");


.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft