Name
AddHeader —
Response.AddHeader
strName, strValue
Synopsis
Allows you to add your own HTTP response header with a corresponding value. If you add an HTTP header with the same name as a previously added header, the second header will be sent in addition to the first; adding the second header does not overwrite the value of the first header with the same name. Also, once the header has been added to the HTTP response, it cannot be removed.
If the client sends the web server an HTTP header other than those
listed in the section on the ServerVariables collection in Chapter 7, you can use
HTTP_HeaderName to retrieve it. For
example, if the client sends the HTTP header:
ClientCustomHeader:CustomHeaderValue
then you could retrieve the value for this element using the following syntax:
<%
Request.ServerVariables("HTTP_ClientCustomHeader")
%>This is an advanced method and should not be used without careful planning. If another method of the Response object will meet your needs, use it instead of using the AddHeader method.
Parameters
-
strName The name of the HTML header you wish to add to the response header
-
strValue The initial value of the new header you are adding to the response header
Example
<% ' The following code adds the CUSTOM-ERROR HTML header to ' the HTTP response headers. Response.AddHeader "CUSTOM-ERROR", "Your browser is not IE." %>
Notes
Like the other methods and properties of the Response object that alter the HTTP response headers, you must call the AddHeader method before ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access