Server Side Redirect

The advantage of the client side re-direction to the user is that the browser is told to display another page. If the user refreshes the page with the function key F5 in the Internet Explorer the correct page will load. Disadvantage: this process requires a complete communication round between client and server.

This problem does not exist when using the server side redirect. Here the AFP executes a second page immediately after completion of a page without re-sending the first page to the browser.  Server.Transfer() attaches the output of the second page to the current page; Response.Call() replaces the output of the first page with the second page.

Server.Transfer( "page2.afp?name="+lcName )

An important aspect of either function is that the invocation deposits the specified page only internally; the execution will not start until the first page has been completed. In many cases you will probably want to use the RETURN command directly afterwards. This behavior is also important with regard to sessions. The session ID is determined at the very first invocation of a page only. Loading and saving session variables is the job of the page itself. Variables declared inside a particular page are not available to the second page.

A server side redirect should be regarded as a new invocation in which the page is not requested by the client but rather directly by the server. This is noticeably faster, although the client does not know it is displaying a different page. If you were to activate the refresh function in your browser it would invoke the first page and not the previously displayed second page.

Server.RedirectLevel() lets you determine how many Server.Transfer() and Response.Call() have already been made. You can utilize this function especially for pages that may only be invoked though other AFP pages to block unauthorized access.

IF Server.RedirectLevel() == 0

  Error.HTTPError( 404 )

  Return

EndIf