please dont rip this site
Platform SDK: IIS SDK
      [IIS 5.0] [IIS 5.1] [IIS 6.0]


The AddHeader method adds a new HTML header and value to the response sent to the client. It does not replace an existing header of the same name. After a header has been added, it cannot be removed.


Response.AddHeader HeaderName, HeaderValue


A string that indicates the name of the new header.
A string that indicates the initial value of the new header.


If a client is configured to return response headers to the server on a subsequent request, you can use Request.ServerVariables to retrieve the custom header value. "HTTP_" is added to the beginning of the custom header name. For example, if you add a header with this code:

<% Response.AddHeader "CustomHeader", "CustomValue" %>

You can retrieve the header if a special client returns it to the server on the next request with the following code:

<% ReturnedValue =index.html Request.ServerVariables("HTTP_CustomHeader") %>

To avoid name ambiguity, HeaderName should not contain any underscore (_) characters. The ServerVariables collection interprets underscores as dashes in the header name. For example, the following script causes the server to search for a header named MY-HEADER:

<% Request.ServerVariables("HTTP_MY_HEADER") %>

If a different Response method can provide the functionality you require, it is recommended that you use that method instead. For example, to send a custom value and have it returned to your Web application on a subsequent request without relying on the configuration of the client, you can use Response.Cookies and Request.Cookies. Or to set cache control for a response, you can use Response.CacheControl.

Because the HTTP protocol requires that all headers be sent before the page content, you must modify all outgoing headers before your ASP script generates any output. In IIS 4.0, this meant that you had to call the AddHeader method in your script before any output was sent to the client, such as output generated by HTML code or the Response.Write method. In IIS versions 5.0 or later, response buffering is on by default. Therefore, you can call the AddHeader method at any point in the script, as long as it precedes any calls to the Response.Flush method. You can enable or disable response buffering by setting the metabase property AspBufferingOn or by using Response.Buffer in an ASP script.

The following .asp file illustrates this point.


Here's some text on your Web page.

' This header tells proxy servers using HTTP/1.0 not to cache this request.

<% Response.AddHeader "Pragma", "no-cache" %>

<% Response.Flush %> 

<% Response.Write("Pragma is set to no-cache") %> 


In the preceding example, because the page is buffered by default, the server will not send output to the client until all the scripts on the ASP page have been processed or until the Response.Flush method is called. If the call to AddHeader appeared after the call to Flush in the preceding example, the script would generate a run-time error.


You can use the AddHeader method to send multiple copies of the same header with different values, as with the WWW-Authenticate headers. The following example uses the AddHeader method to request that the client use Basic authentication:

<% Response.Addheader "WWW-Authenticate", "BASIC" %>

The preceding script only informs the client browser of which type of authentication to use; it does not specify that the Web server enable Basic authentication for the application.

Applies To

Response Object

See Also


Platforms: Windows 2000 with IIS 5.0 installed, Windows XP with IIS 5.1 installed, Windows Server 2003 family with IIS 6.0 installed

Platform SDK Release: February 2003
What did you think of this topic?
Order a Platform SDK CD

file: /Techref/language/asp/OBJ/ref_vbom_resomah.htm, 6KB, , updated: 2003/5/15 14:13, local time: 2024/6/19 04:09,

 ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF=""> Response.AddHeader</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.

Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

  PICList 2024 contributors:
o List host: MIT, Site host, Top posters @none found
- Page Editors: James Newton, David Cary, and YOU!
* Roman Black of Black Robotics donates from sales of Linistep stepper controller kits.
* Ashley Roll of Digital Nemesis donates from sales of RCL-1 RS232 to TTL converters.
* Monthly Subscribers: Gregg Rew. on-going support is MOST appreciated!
* Contributors: Richard Seriani, Sr.

Welcome to!