119 lines
6.3 KiB
HTML
119 lines
6.3 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
|
<HTML>
|
|
<HEAD>
|
|
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=Windows-1252">
|
|
<TITLE>AddHeader</TITLE>
|
|
<SCRIPT LANGUAGE="JavaScript">
|
|
<!--
|
|
TempString = navigator.appVersion
|
|
if (navigator.appName == "Microsoft Internet Explorer"){
|
|
// Check to see if browser is Microsoft
|
|
if (TempString.indexOf ("4.") >= 0){
|
|
// Check to see if it is IE 4
|
|
document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/coua.css">');
|
|
}
|
|
else {
|
|
document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/cocss.css">');
|
|
}
|
|
}
|
|
else if (navigator.appName == "Netscape") {
|
|
// Check to see if browser is Netscape
|
|
document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/coua.css">');
|
|
}
|
|
else
|
|
document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/cocss.css">');
|
|
//-->
|
|
</script>
|
|
<SCRIPT LANGUAGE="VBScript">
|
|
<!--
|
|
Sub Window_OnLoad()
|
|
Dim frmContents
|
|
On Error Resume Next
|
|
If Not Parent Is Nothing Then
|
|
Set frmContents = Parent.Contents
|
|
If Not frmContents Is Nothing Then
|
|
frmContents.Window.TOCSynch_Click
|
|
End If
|
|
End If
|
|
End Sub
|
|
//--></SCRIPT><META NAME="DESCRIPTION" CONTENT="Internet Information Services reference information">
|
|
<META HTTP-EQUIV="PICS-Label" CONTENT='(PICS-1.1 "<http://www.rsac.org/ratingsv01.html>" l comment "RSACi North America Server" by "inet@microsoft.com <mailto:inet@microsoft.com>" r (n 0 s 0 v 0 l 0))'>
|
|
<META NAME="MS.LOCALE" CONTENT="EN-US">
|
|
<META NAME="MS-IT-LOC" Content="Internet Information Services">
|
|
</HEAD>
|
|
|
|
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
|
|
|
|
<H4><A NAME="_addheader"></A><SUP></SUP>AddHeader</H4>
|
|
|
|
<P>The <B>AddHeader </B>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. Once a header has been added, it cannot be removed.</P>
|
|
|
|
<H6>Syntax</H6>
|
|
|
|
<P><B>Response.AddHeader</B> <I>HeaderName</I><B>,</B> <I>HeaderValue</I></P>
|
|
|
|
<P><I> </I></P>
|
|
|
|
<H6>Parameters</H6>
|
|
|
|
<DL>
|
|
<DT><I>HeaderName</I></DT>
|
|
|
|
<DD>A string that indicates the name of the new header.<BR>
|
|
</DD>
|
|
|
|
<DT><I>HeaderValue</I></DT>
|
|
|
|
<DD>A string that indicates the initial value of the new header.</DD>
|
|
</DL>
|
|
|
|
<H6>Note</H6>
|
|
|
|
<P>If a client is configured to return response headers back to the server on a subsequent request, you may use <B>Request.ServerVariables</B> to retrieve the custom header value. "HTTP_" will be pre-pended to the custom header name. For example, if you add a header with this code:</P>
|
|
|
|
<PRE><CODE><% Response.AddHeader "CustomHeader", "CustomValue" %></CODE></PRE>
|
|
|
|
<P>You can retrieve the header if a special client returns it to the server on the next request with this code:</P>
|
|
|
|
<PRE><CODE><% ReturnedValue = Request.ServerVariables("HTTP_CustomHeader") %></CODE></PRE>
|
|
|
|
<P>To avoid name ambiguity, <I>HeaderName</I> should not contain any underscore (_) characters. The <B>ServerVariables</B> 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.</P>
|
|
|
|
<PRE><CODE><% Request.ServerVariables("HTTP_MY_HEADER") %></CODE></PRE>
|
|
|
|
<P>If another <B>Response </B>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 <B>Response.Cookies</B> and <B>Request.Cookies</B>; or to set cache control for a response, use <B>Response.CacheControl</B>.</P>
|
|
|
|
<P>Because the HTTP protocol requires that all headers be sent before 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 <B>AddHeader </B>in your script before any output was sent to the client, such as output generated by HTML code or the <A HREF="/iishelp/iis/htm/asp/vbob2w2t.htm"><B>Write</B></A> method. In IIS versions 5.0 or later, response buffering is on by default. Therefore, you can call the <B>AddHeader </B>method at any point in the script, as long as it precedes any calls to <A HREF="/iishelp/iis/htm/asp/vbob74tk.htm"><B>Flush</B></A>. You can enable or disable response buffering by setting the metabase property <A HREF="/iishelp/iis/htm/asp/apro719q.htm"><B>AspBufferingOn</B></A> or making a call to Response.Buffer in an ASP script.</P>
|
|
|
|
<P>The following .asp file illustrates this point.</P>
|
|
|
|
<PRE><CODE><HTML>
|
|
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") %>
|
|
</HTML></CODE></PRE>
|
|
|
|
<P>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 <A HREF="/iishelp/iis/htm/asp/vbob74tk.htm"><B>Flush</B></A> method is called. If the call to <B>AddHeader</B> appeared after the call to <B>Flush </B>in the preceding example, the script would generate a run-time error.</P>
|
|
|
|
<H6>Example</H6>
|
|
|
|
<P>You can use <B>AddHeader </B>to send multiple copies of the same header with different values, as with the WWW-Authenticate headers. The following example uses the <B>AddHeader</B> method to request that the client use Basic authentication.</P>
|
|
|
|
<PRE><CODE><% Response.Addheader "WWW-Authenticate", "BASIC" %></CODE></PRE>
|
|
|
|
<P>The preceding script only informs the client browser which type of authentication to use; it will not tell your Web server to enable Basic authentication for the application.</P>
|
|
|
|
<H6>Applies To</H6>
|
|
|
|
<P><A HREF="/iishelp/iis/htm/asp/vbob5sj8.htm"><B>Response</B> Object</A></P>
|
|
|
|
<H6>See Also</H6>
|
|
|
|
<P><A HREF="/iishelp/iis/htm/asp/vbob74tk.htm"><B>Flush</B></A>, <A HREF="/iishelp/iis/htm/asp/vbob2w2t.htm"><B>Write</B></A>, <A HREF="/iishelp/iis/htm/asp/vbob1fsi.htm"><B>Buffer</B></A></P>
|
|
<hr class="iis" size="1">
|
|
<p align="center"><em><a href="../../../common/colegal.htm">© 1997-2001 Microsoft Corporation. All rights reserved.</a></em></p>
|
|
</BODY>
|
|
</HTML>
|