Skip to main content

%Response Example: Redirection

Complete the following steps to use redirection with %response and its Redirect property.

  1. Add the following script to the <Body> section of StateTest.csp while leaving the existing code unchanged. The script defines the onPreHTTP method for the page. The method tests the value of the password entered into SignIn.CSP. If the value is not “CSP” the method redirects the user to Error.CSP (See the note below for the location of this file). Otherwise, StateTest.CSP loads. Note that onPreHTTP returns 1. If it returned 0, then StateTest.CSP would not load.

    
    <script language="cache" method="OnPreHTTP" arguments="" 
    returntype="%Boolean">
    if ($Get(%request.Data("txtPassword",1)) '= "CSP")
    {
      set %response.Redirect="Error.CSP"
    }
    quit 1
    </script>
    
  2. Open SignIn.CSP in a Web Browser. Enter text other than “CSP” into the password field.

    generated description: responseexample signin20142

  3. Click SignIn. The browser is redirected to Error.CSP

    generated description: responseexample2 signin20142

  4. Open SignIn.CSP in a Web Browser. Enter “CSP” into the password field.

    generated description: requestexample signin20142

  5. Click SignIn. StateTest.CSP loads into the browser.

    generated description: responseexample420142

Note:

Error.CSP is one of the example files that accompany the tutorial. For information on installing the example files, read Installing Tutorial Files.

FeedbackOpens in a new tab