Article ID: 159402 - View products that this article applies to.
This article was previously published under Q159402
The Redirect method of the Response object operates by sending a header to the client. This header causes the client to look to another URL location specified in the header. Because a header must come at the beginning of a document, it is not possible to place the Redirect method in a document with HTML code preceding it.
To work around this behavior you can use the buffering capabilities of the Response object. In doing this you can output HTML code into the buffer until you reach a point where you use the Redirect method. If at this point you need to redirect to another page, you clear the buffer and then issue the Response.Redirect.
When trying to use the Response.Redirect method in a server-side script, the following error can occur when the page is accessed:
Response object error 'ASP 0156 : 80004005
/<page.asp>, line 9
The HTTP headers are already written to the client browser. Any HTTP header modifications must be made before writing page content.
The above example always redirects to the file named Filename.asp.
Note Setting the Response.Buffer = True is not necessary in Windows 2000 because it is True by default.
Article ID: 159402 - Last Review: October 26, 2007 - Revision: 5.3