RedirectRequest Method  
 

Redirect the request from the client to another URL.

Syntax

object.RedirectRequest( ClientId, Location, [Method] )

Parameters

ClientId
An integer that identifies the client session.
Location
A string that specifies the new location for the requested resource. This value must be a complete URL, including the http:// or https:// scheme.
Method
An optional integer value that specifies if the redirection is permanent or temporary. If this parameter is omitted, the client will be informed that the redirection is temporary. One of the following values may be used:
Value Constant Description
1 httpRedirectPermanent This value is used for permanent redirection, indicating that the client should update any record of the link with the new URL specified by the Location parameter. This result is cacheable and when the client makes subsequent requests for the resource, it should always use the new URL.
2 httpRedirectTemporary This value is used for temporary redirection, indicating that the client should issue a request for the resource using the new URL specified by the Location parameter, but subsequent requests should continue to use the original URL.
3 httpRedirectOther This value is used for temporary redirection, however it instructs the client that it should use the GET command to request the redirected resource. This option is typically used to redirect a client after it has used the POST command.

Return Value

A value of zero is returned if the method completed successfully. Otherwise, a non-zero error code is returned which indicates the cause of the failure.

Remarks

The RedirectRequest method can be used within an OnCommand event handler to redirect the client to a new location for the resource that it has requested. This redirection can be permanent or temporary, depending on whether the server expects the client to continue to use the original URL when requesting the resource.

If httpRedirectTemporary is specified, the actual status code that is returned to the client depends on the version of the protocol that is being used. If the client has issued the request using HTTP 1.0 then the server will return a 302 code to the client. If the client used HTTP 1.1, the server will return a 307 code to the client that indicates it should use the same command verb (GET, POST, etc.) when requesting the resource at the new location.

If httpRedirectOther is specified, the status code that is returned to the client depends on which version of the protocol is being used. For clients who are using HTTP 1.0, the server will return a 302 code to the client just as with httpRedirectTemporary. If the client is using HTTP 1.1, the server will return a 303 code to the client that indicates it should always use the GET command to request the new resource, regardless if a different command was originally used (POST, PUT, etc.)

This method provides a simplified interface for sending a redirection status code that also implicitly sets the Location response header to the value of the Location parameter. If the server application needs to send alternate redirection codes such as 305 (Use Proxy) then it should use SetHeader method to set the value of the Location response header, followed by the SendReponse method to send the redirection status code.

See Also

SendError Method, SendResponse Method, OnCommand Event