Response.Redirect tells the visitor’s browser to request a different URL. In Classic ASP, call it before HTTP headers have been sent; do not place it after a Response.Flush that has committed those headers.
<%
Response.Redirect "https://www.plus2net.com/asp-tutorial/response.php"
%>
The browser makes a new request for the destination. The original example used https://www.sitename.com; substitute the actual, trusted destination for your application.
Response.Redirect "destination-url"
Use a full URL to redirect to another site or a root-relative URL to stay on the same site:
<%
Response.Redirect "/asp-tutorial/response-write.php"
%>
When headers have already been committed, attempting a redirect can raise a Classic ASP header error. The original lesson showed a representative ASP 0156 error:
Response object error 'ASP 0156 : 80004005'
Header Error
The HTTP headers are already written to the client browser.
Make the routing or login decision at the start of the page, before HTML output, flushing, or other operations that commit the response.
<%@ Language="VBScript" %>
<% Option Explicit
Response.Buffer = True
Response.Redirect "/asp-tutorial/response.php"
%>
Save as an .asp page on IIS. It redirects without rendering a normal HTML page; the buffer setting must be made before any content is sent.
<%@ Language="VBScript" %>
<% Option Explicit
Response.Buffer = True
Dim signedIn
signedIn = (Session("userid") <> "")
If Not signedIn Then
Response.Redirect "/asp-tutorial/lg-login.php"
End If
Response.Write "Login session is present."
%>
Do not pass an untrusted query-string value directly into Response.Redirect. Restrict the destination to a list of trusted, intended routes:
<%
Dim pageKey, destination
pageKey = LCase(Trim(Request.QueryString("page")))
Select Case pageKey
Case "write"
destination = "/asp-tutorial/response-write.php"
Case "flush"
destination = "/asp-tutorial/response-flush.php"
Case Else
destination = "/asp-tutorial/response.php"
End Select
Response.Redirect destination
%>
The query parameter can choose only one of the allowed paths. This prevents an attacker from making your site redirect visitors to arbitrary external URLs.
A common workflow saves form data and then redirects to a result page to avoid repeating a form submission on refresh. For a real form, validate the input, perform the write safely, and only then redirect:
<%
If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
' Validate and save the form data here.
Response.Redirect "/asp-tutorial/response.php"
End If
%>
This is an outline, not a complete database handler. A conventional Classic ASP Response.Redirect issues a temporary redirect; if a specific HTTP status is required, configure it deliberately at the appropriate server layer.
| Method | Behavior |
|---|---|
Response.Redirect | Browser navigates to another URL |
Response.End | Ends this response; no new destination |
Response.Flush | Commits/sends currently buffered output |
Response.Clear | Drops unsent body output |
If ASP reports a header error, ensure the redirect occurs before output is sent. If the browser stays on the same page, check for a wrong URL or redirect loop. If user input controls the destination, allowlist possible targets. For server-level permanent redirects, see the ASP redirect guide and your IIS configuration.
For a comparison in another language, see header redirects in PHP. Classic ASP uses Response.Redirect rather than PHP's header().
Classic ASP Response.Redirect ordinarily performs a temporary redirect. For permanent relocation, configure an appropriate 301 at IIS/server level rather than assuming the method is permanent.
Yes. Use a suitable root-relative path or an absolute URL.
No. Classic ASP Response.Redirect already terminates processing; adding Response.End is unnecessary.
Not after response headers are committed. Put redirect decisions before any flush.
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.