How can I handle a redirect in HTTP?

How can I handle a redirect in HTTP?

Date Entered: 01/11/2000    Last Updated: 04/23/2008

Version 5 of IPWorks includes a FollowRedirects property that you can use to automatically handle redirections. For example:
HTTP1.FollowRedirects = frAlways
HTTP1.Get ""
In previous versions of IPWorks: The server gives the new location in the Location header and then returns an error number 301 or 302. The http control will generate an error/exception with the text "Redirected." You should save the Location header in the Header event, handle the error/exception generated/raised by the control and request this new location.

An example in VB is shown below:

     Dim gNewURL as String

     Private Sub HTTP1_Header(Field As String, Value As String)
        If LCase(Field) = "location" Then gNewURL = Value
     End Sub

     Private Sub Command1_Click()
     On Error GoTo errhandler
        HTTP1.WinsockLoaded = True
        HTTP1.URL = ""
        HTTP1.Action = a_GetDocument
        Exit Sub
           If Err.Number = 20152 And (Left(Error, 4) = "303 " Or _
                    Left(Error, 4) = "302 ") Then
              HTTP1.URL = gNewURL 'assign new URL
              Resume   'repeat action
           End If
     End Sub

We appreciate your feedback.  If you have any questions, comments, or suggestions about this entry please contact our support team at