ASP Response Object : Redirect Method
The Redirect method stops processing the current script and tries to connect the end user to a different URL. To accomplish this, the following explicit HTTP header is sent to the end user's browser:
HTTP 1.1 302 Object Moved
is the parameter
passed to the Redirect
method. If, however, page content has already been sent to the end user and a proxy server
lies between the server and end user, an error message
can be generated. To prevent this, Response.Buffer
should be set to True
should be called just before calling the Redirect
This method takes one mandatory parameter:
- URL - the URL to send the end user to
Response.Buffer = True
'any amount of code, response.writes, etc...
This will redirect
the user to Everything
, regardless of the code
Tips & Hints
Transfer Instead of Redirecting for Internal Pages
With the introduction of ASP 3.0 and IIS 5.0 came some new functionality which largely makes the use of the Redirect method obsolete for internal pages (pages on the same server). You should now use Server.Transfer instead of the Redirect method to send users to different pages on your system.
The reason is that a redirect forces a new page request, resulting in the browser having to connect again to the web server and the server having to handle an extra request. Server.Transfer, on the other hand, transfers execution to a different ASP page on the same server, avoiding the extra browser-to-server connection and resulting in better performance.
Back to the ASP Response Object
Back to ASP Objects
1 As long as Response.End or Server.Transfer aren't called.
All code is my own (and is a seventh cousin of EDB's).