Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
setRedirectCode(redirectCode)
Sets the HTTP redirect code to use for the PageReference object when
setRedirect(redirect) is set to true.
Signature
public System.PageReference setRedirectCode(Integer redirectCode)
Parameters
-
redirectCode: Type: Integer
Valid values:
- 0 — Redirect using the default redirect action for this PageReference. Typically a JavaScript-based redirection or HTTP 302.
- 301 — Moved Permanently. Redirect users by sending an HTTP GET request to the target location. Includes instructions to update any references to the requested URL with the target location.
- 302 — Moved Temporarily. Redirect users by sending an HTTP GET request to the target location. Because the redirection is temporary, it doesn’t include update instructions.
- 303 — See Other. Redirect users by sending an HTTP GET request to the target location. Not commonly used. Useful when the client sends a POST request and you want the client to call the new web page using a GET request instead of a POST request.
- 307 — Temporary Redirect. Send the same HTTP request, regardless of the HTTP method, to the target location. Because the redirection is temporary, it doesn’t include update instructions.
- 308 — Permanent Redirect. Send the same HTTP request, regardless of the HTTP method, to the target location. Includes instructions to update any references to the requested URL with the target location.
If the redirect code contains an invalid integer, an error message is displayed when PageReference is used by Salesforce for redirection.
Return Value
Type: System.PageReference