Redirecting Examples

By default, the component follows redirects automatically that are sent by the Web server. You can, however, disable redirects using the FollowRedirects property. With FollowRedirects set to False, you can learn the redirect target by examining the RedirectTarget property. Note: redirects sends a HTTP status 302.

Example (Redirects.asp)

<%  @LANGUAGE=VBSCRIPT %>
<% 
' Written by: Christoph Wille
' Last updated: 5/22/2001

Option Explicit
Response.Expires = 0
%>

<!-- #include file="asptearinclude.asp" -->
<html>
<head><title>No redirects</title></head>
<body bgcolor=#ffffff>

<%
Const cstrRedirHelper = "http://webdevsrv01/AspTear/RedirectsHelper.asp"

Dim xObj, strResult, strUrl
Set xobj = Server.CreateObject("SOFTWING.ASPtear")

On Error Resume Next

' don't follow any redirects; default is to follow any redirect proposed by the server
xObj.FollowRedirects = False
strResult = xobj.Retrieve(cstrRedirHelper, Request_HEAD, "", "", "")

HandleErrorEx False

Response.Write "<font color=""red"">" & strResult & "</font>"
Response.Write "<br><b>Headers:</b><br><PRE>" & xObj.Headers & "</PRE>"

Response.Write "<p>New Location: " & xObj.RedirectTarget & "</p>"
%>


</body>
</html>
RedirectsHelper.asp
<%  @LANGUAGE=VBSCRIPT %>
<% 
' Written by: Christoph Wille
' Last modified: 5/22/2001

Option Explicit
Response.Expires = 0
 
' This file is used by "Redirects.asp" to illustrate
' how to manually follow redirect requests
Response.Redirect "http://www.alphasierrapapa.com/"
%>