SetHeader
SetHeader method
Use this method to set an HTTP header to be sent with the response to the client/browser.
| Method Prototype | Description
|
| Sub SetHeader( name As String, value As String, replace As Boolean = True) | set an HTTP header
|
An HTTP response consists of a series of headers providing metadata about the response, followed by the response content itself. In most cases you don't need to worry about the headers, as the most important ones (e.g. Content-Length) are calculated for you. But occasionally you may need to set a header directly. The SetHeader method allows you to do that. Simple call SetHeader (a global method) with the name and value of the header to set.
The third parameter is optional and defaults to True; when true, SetHeader will first remove any previously set headers of the same name before setting the new value. If you pass False, then the call will add an additional header, even if one (or more) of the same name exists. (This is legal, though rarely useful.)
Special HeadersWhen you set the "Location" header (which specifies the target for a redirect), the HTTP Status is automatically set to 302 (a redirect). So, to redirect the client to another page, simply call SetHeader "Location" with the address of the other page as the value. (You can of course override this with
SetStatus.)