Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

Redirecting in ASP Using Response.Redirect

IIS 6.0

The Response.Redirect method of the ASP built-in object can be used to redirect requests from inside an ASP page.

The following ASP code example shows you how to use the Visual Basic Scripting Edition (VBScript) to redirect the user back to an HTML form page if they failed to supply three items of data in a form. If any output is sent to the client before the redirection, redirection fails.

<%@ Language="VBScript" %> 

<% 
Dim Missing 
Missing = False 

For each i in Request.Form 
If "" = Request.Form(i).item Then 
Missing = True 
End If 
Next 

If Missing Then 
Response.Redirect(Request.ServerVariables("HTTP_REFERER")) 
Else 
' Verify that the form data contains only valid characters. 
' Other ASP code. 
End If 
%>

<%@ Language="JScript" %> 

<% 
var Missing = false; 

e = new Enumerator(Request.Form); 
for (; !e.atEnd(); e.moveNext()) { 
Item = e.item(); 
if ("" == Request.Form(Item)) { 
Missing = true; 
} 
} 

if (Missing) { 
Response.Redirect(Request.ServerVariables("HTTP_REFERER")); 
} else { 
// Verify that the form data contains only valid characters. 
// Other ASP code. 
} 
%>

Show:
© 2015 Microsoft