The Redirect method causes the browser to redirect the client to a different URL.
Any response body content such as displayed HTML text or Response.Write text in the page indicated by the original URL is ignored. In addition, code execution in the current page is terminated when the Redirect method is processed, so subsequent code in the page will also be ignored.
However, this method does send other HTTP headers set by this page indicated by the original URL to the client. An automatic response body containing the redirect URL as a link is generated. The Redirect method sends the following explicit header, where URL is the value passed to the method, as shown in the following code:
HTTP 1.0 302 Object Moved Location: http://www.microsoft.com
The following example shows you how to use the VBScript programming language to redirect the user to the Microsoft Web site after validating the URL.
<%@ LANGUAGE="VBScript" %> <% Dim MyUrl MyUrl = "http://www.microsoft.com" Response.CodePage = 1252 If ValidateInput(MyUrl) Then Response.Redirect (myURL) Else Response.Write("URL was invalid.") End If Function ValidateInput(sInput) Dim reValid Set reValid = New RegExp reValid.Pattern = "^[\w\.:\?&=/]*$" reValid.MultiLine = False reValid.Global = True ValidateInput = reValid.Test(sInput) End Function %>
The following example shows you how to use the VBScript programming language to redirect the user to a virtual directory on the same IIS server.
The following example shows you how to use the VBScript programming language to redirect the user to a local file while passing a query string.
Form and query string data is not transferred to the new URL. The following example shows you how to use the VBScript programming language to pass a querystring from the original request to the new URL.
Client: Requires Windows XP Professional, Windows 2000 Professional, or Windows NT Workstation 4.0.
Server: Requires Windows Server 2003, Windows 2000 Server, or Windows NT Server 4.0.