Automatically-redirect-when-301-or-301-is-received - WeOnlyDo Software example code



All

wodCrypt (12)
wodSSH (10)
wodSFTP (23)
wodSSHServer (1)
wodSSHTunnel (11)
wodSSHpackage
wodSFTPdll

wodSSH.NET (10)
wodSFTP.NET (24)
wodFtpDLX.NET (22)
wodWebServer.NET (10)

wodAppUpdate (13)
wodHttpDLX (8)
wodFtpDLX (22)
wodTelnetDLX
wodFTPServer (3)
wodWebServer (10)
wodVPN
wodXMPP (13)
All ** [Visual Basic] ** [C#] ** [VB.NET] **

Automatically redirect when 301 or 301 is received
VB code
Dim WithEvents wodHttp As wodHttpDLXCom
Private Sub Form_Load()
    ' Initialize the component
    Set wodHttp = New wodHttpDLXCom
    
    ' Set AutoRedirect property to toggle Autoredirection On/Off    
    wodHttp.AutoRedirect = True
    
    ' Now, let's get the page
    wodHttp.Get "http://weonlydo.com"
    
End Sub

' When component is done executing, Done event is triggered. We can
' check response here
Private Sub wodHttp_Done(ByVal ErrorCode As Long, ByVal ErrorText As String)
    ' If no Error occured, ErrorCode will return 0
    If ErrorCode = 0 Then
        MsgBox wodHttp.Response.Body
    Else
        MsgBox ErrorText
    End If
End Sub

' HeadersDone will be triggered twice. First with 301 reply, second time with 200.
Private Sub wodHttp_HeadersDone()
    Debug.Print wodHttp.Response.StatusCode
End Sub
VB.Net code
Dim WithEvents wodHttp As wodHttpDLXComLib.wodHttpDLXCom
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    ' Initialize the component
    wodHttp = New wodHttpDLXComLib.wodHttpDLXCom
    
    ' Set AutoRedirect property to toggle Autoredirection On/Off     
    wodHttp.AutoRedirect = True

    ' Now, let's get the page
    wodHttp.Get("http://weonlydo.com")
End Sub

' When component is done executing, Done event is triggered. We can
' check response here
Private Sub wodHttp_Done(ByVal ErrorCode As Integer, ByVal ErrorText As String) Handles wodHttp.Done
    ' If no Error occured, ErrorCode will return 0
    If ErrorCode = 0 Then
        MsgBox(wodHttp.Response.Body)
    Else
        MsgBox(ErrorText)
    End If
End Sub

' HeadersDone will be triggered twice. First with 301 reply, second time with 200.
Private Sub wodHttp_HeadersDone() Handles wodHttp.HeadersDone
    Debug.Print(wodHttp.Response.StatusCode)
End Sub
C# code
private wodHttpDLXComLib.wodHttpDLXComClass wodHttp;
private void Form1_Load(object sender, EventArgs e)
{
    // Initialize the component and declare Done event
    wodHttp = new wodHttpDLXComLib.wodHttpDLXComClass();
    wodHttp.Done += new wodHttpDLXComLib._IwodHttpDLXComEvents_DoneEventHandler(wodHttp_Done);
    wodHttp.HeadersDone += new wodHttpDLXComLib._IwodHttpDLXComEvents_HeadersDoneEventHandler(wodHttp_HeadersDone);
    
    // Set AutoRedirect property to toggle Autoredirection On/Off
    wodHttp.AutoRedirect = true;

    // Now, let's get the page
    wodHttp.Get("http://weonlydo.com");
}

// When component is done executing, Done event is triggered. We can
// check response here
void wodHttp_Done(int ErrorCode, string ErrorText)
{
    // If no Error occured, ErrorCode will return 0
    if(ErrorCode == 0)
    {
        MessageBox.Show(wodHttp.Response.Body);
    }
    else
    {
        MessageBox.Show(ErrorText);
    }
}

// HeadersDone will be triggered twice. First with 301 reply, second time with 200.
void wodHttp_HeadersDone()
{
    Console.WriteLine(wodHttp.Response.StatusCode.ToString());
}