Skip to content

Controller

getRedirect()

getRedirect() — returns struct

Available in: controller Category: Miscellaneous Functions

Primarily used in testing scenarios to determine whether the current request has performed a redirect. It returns a structure containing information about the redirect, such as the target URL and the HTTP status code. This allows you to verify redirect behavior in automated tests without actually sending the user to another page.

1. Get redirect information for the current request
redirectInfo = getRedirect();

// Check if a redirect occurred
if (structKeyExists(redirectInfo, "url")) {
    writeOutput("Redirected to: " & redirectInfo.url);
    writeOutput("HTTP status: " & redirectInfo.status);
} else {
    writeOutput("No redirect occurred.");
}