Name

Redirect — Response.Redirect strURL

Synopsis

Redirects the client's request to another URL.

Parameters

strURL

The Universal Resource Locator string for the new location to which you wish to redirect the client

Example

<% 
' The following code determines whether the client has
' security clearance for a certain page. If not, it 
' is redirected to another URL.
[...Code to determine user's clearance for the current page...]

If Not(strUserSecurity = "ADMIN" or strUserSecurity = "SUPERADMIN") Then
   Response.Redirect "/security/noclearance.asp?usrid=09563"
End If
%>

Notes

The strURL value you use when calling the Redirect method can be an exact URL with DNS or a virtual directory and filename. It also can be the name of a file that resides in the same folder as the requested page.

If your script has written any content to the HTTP response body, that content is ignored by the script once the call to the Redirect method is executed.

Calling the Redirect method is conceptually the same as setting the Status property to "302 Object Moved" and sending the user to a new location using the Location HTTP header.

Note that upon redirection, some older (HTTP 1.0) client browsers will mistakenly change POST requests to GET requests when the new URL is called. This is an important consideration when the client's POSTed information contains more data than the GET method can handle. It is assumed that new browsers supporting the HTTP 1.1 protocol have fixed this problem.

If your ASP file is running ...

Get ASP in a Nutshell, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.