Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
The Response.Redirect method of the ASP built-in object can be used to redirect requests from inside an ASP page.
Example Code
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.
}
%>