Response Object
Context.Response object."/>Description
The Response object is used with the Alpha Anywhere Classic Application Server. To access the Request object in the Alpha Anywhere Application Server for IIS, use the Context.Response object.
Discussion
Alpha Anywhere pages have access to a system object named Response. This object represents the HTTP response that will be created by the Application Server and sent back to the client. It has a number properties and methods available. The server creates this object for each client Response and can be accessed directly by your applications.
Response Object Comparison to Other Environments
The chart below is intended to directly compare the Application Server's Response object to other popular web application platforms in order to assist developers familiar with those platforms.
Description | A5W Property | ASP Equivalent | PHP Equivalent |
---|---|---|---|
Enable/disable response output buffering | N/A Output is always buffered | Buffer | ob_start() print ob_end_flush() |
Set caching directives to indicate how this response should be cached by the client and any proxies | Response.AddHeader("Cache-Control", "") | CacheControl | No specific equivalent. Typically implemented using the Header() function. |
Set the content type of the outgoing HTTP response. | Response.Charset | Charset | |
The MIME type that will be sent back to the browser. | Response.Mime_Type If you do not know the appropriate MIME type for a given file type, but you know that file's extension, the A5W environment offers the RESOLVE_MIME_TYPE() helper function to translate the extension into the proper MIME type. | ContentType | |
Set an expiration time for this resource when it is stored in a cache | Response.Expire() | Expires ExpiresAbsolute | |
Prevent the resource from ever being cached by the client or any proxies | Response.NoCache() | Requires setting several different properties individually | Requires creating several different headers individually |
Set the PICS (Platform for Internet Content Selection) Label HTTP response header | Response.AddHeader("PICS-Label", "") | PICS | No specific equivalent. Typically implemented using the Header() function. |
The HTTP reason phrase that describes the status of the response. | Response.Reason_Phrase | Status | |
The 3 digit HTTP status code that describes the status of the response. | Response.Status_Code | ||
Output data | ? Unlike ASP, A5W is binary aware, so there is only a single method required. | Response.Write() Response.WriteBinary() | print print_r |
Terminate a script | End | Response.End() | |
Add a cookie to the response | Response.AddCookie() | Response.Cookie() | Setcookie() |
Add an HTTP header to the response | Response.AddHeader() | Response.AddHeader() | Header() |
Redirect the client (web browser) to the specified URL | Response.Redirect() | Response.Redirect() | Header() |
Properties
- Response.Charset
Specifies the Charset header for the outgoing response.
Example
Response.Charset = "UTF-8"
- Response.Mime_Type
Specifies the Content-Type header for the outgoing response.
Example
Response.Mime_Type = "application/pdf"
- Response.Reason_Phrase
Specifies the HTTP Reason Phrase for the outgoing response.
- Response.Status_Code
Specifies the HTTP Status Code for the outgoing response.
Methods
- Response.AddCookie
- cookieCharacter
The cookie name.
- valueCharacter
The cookie value to store.
- lifetimeInSecondsNumeric
The cookie's lifetime in seconds. The cookie expires after the specified period of time.
- flagHTTPOnlyLogical
If .t., cookie is created as an Http-Only cookie.
- flagSecureLogical
If .t., cookie is create as a Secure cookie.
Sets a cookie to be sent back to the client as part of the response. Supports Http-Only and Secure cookies using the flagHTTPOnly and flagSecure properties.
Example' Set a cookie that expires in 15 minutes Response.AddCookie("MyCookie","MyValue",900) ' Set an Http-Only cookie: Response.AddCookie("MyCookie","MyValue",900,.t.) ' Set a Secure cookie: Response.AddCookie("MyCookie","MyValue",900,.f.,.t.) ' Set a Secure Http-Only cookie: Response.AddCookie("MyCookie","MyValue",900,.t.,.t.)
- Response.Add_Cookie
- This method is obsolete. Use Response.AddCookie. See Replacing Response.Add_Cookie().
- Response.AddHeader
- headerCharacter
The header. Both the header and value can be specified using this parameter using the format "header: header_value".
- headerValueCharacter
The header value. Required if you are using ASP-like syntax to specify the header. See example below.
Sets a header to be sent back to the client as part of the response.
Example' Using "classic" syntax: Response.AddHeader("MyHeader: abc123") ' Using ASP-like syntax: Response.AddHeader("MyHeader","def456")
- Response.Add_Header
- This method is obsolete. Use Response.AddHeader. See Replacing Response.Add_Header()
- Response.Expire
- timeCharacter
Specifies when the response expires. Value can be a length of time specified as seconds, minutes, hours, days or weeks, a specific time, or immediately (use "-1" to specify response expires immediately.) See examples below.
Sets a header to indicate when the client should expire this response from its cache.
Example' Expire in 5 minutes: Response.Expire("5 minutes") 'supports seconds, minutes, hours, days, and weeks ' Expire at a specific time: Response.Expire("3/29/12 03:07") ' or Response.Expire("Thu, 29 Mar 2012 07:07:00 GMT") ' Expire immediately: Response.Expire("-1")
- Response.NoCache
Sets headers to indicate that the client should not store this response in its cache at all.
- Response.Redirect
- urlCharacter
The URL to redirect the browser.
- permanentRedirectLogical
Default value is .f.. If .t., a permanent (301) redirect will be used. If unspecified or .f., a temporary (302) redirect is used.
This method has been extended to support permanent (301) redirects using an optional second argument. If left unspecified or set to .F., the redirect is a temporary (302) redirect, while setting the second argument to .T. results in a 301 redirect. The end result is generally the same in most clients, but 301 and 302 redirects are typically handled differently by search engines and caches.
ExampleResponse.Redirect("/newpage.a5w",.t.)
- Response.SendFile
- fileCharacter
The full path and file name to the file on the server. The file must always be specified using an absolute path.
- downloadedFileNameCharacter
The file name to use in the client when downloading the file.
Response.SendFile() can be used to send a file to the client from anywhere on the filesystem that is accessible by the user account used to run the server, including outside the server's document root. The file to be sent must always be specified using an absolute path.
Example' Send a file: Response.SendFile("c:\invoice.docx") ' Send a file with a different filename on the client: Response.SendFile("c:\invoices\customer0023.docx","invoice.docx")
See Also