Redirect a page using Response.Redirect URL, where URL is a string (Example 1).
One caution: because ASP is a server-side technology, it can't just arbitrarily change the location of a page like client-side script can. It needs to communicate it's request through the HTTP page header.
This means that ASP has to wait until it 'knows' what kind of content it will be sending, in order to know what sort of header to write. This is why Example 2 will return an error.
Example 3 holds all output untill the content is decided one way or another.
<% ' EXAMPLE 1 ' SIMPLE PAGE REDIRECTION: Response.Redirect "http://www.irt.org/" %> <% ' EXAMPLE 2 ' THIS RETURNS AN ERROR Response.Write "Hello World" Response.Redirect "http://www.irt.org/" %> <% ' EXAMPLE 3 ' THIS SOLVES THE PROBLEM ' HOLD OUTPUT BACK FOR NOW: Response.Buffer = True ' DECIDE ON CONTENT TYPE" If sayHello = True Then Response.Write "Hello World" Else Response.Redirect "http://www.irt.org/" End If ' WRITE THE HTTP HEADER AND CONTENT: Response.Flush %>
Using IIS5.0 that comes with windows 2000 advanced server you do not need to set a response.buffer = true. This is only needed for IIS4.0 and lower.