Forum Discussion

Chris_Bingham_1's avatar
Chris_Bingham_1
Icon for Nimbostratus rankNimbostratus
May 19, 2005

New Kid Needs Help(My First iControl VB.NET)

Greeting All!

 

 

I am getting the following error when tyring to connect with a simple VB.NET iControl App.

 

 

    
    An unhandled exception of type 'System.Net.WebException' occurred in system.web.services.dll    
        
    Additional information: The request failed with HTTP status 400: Bad Request.    
    

 

 

I just tried to copy Joe's example in the .NET sample video (well I used vb instead of c). What am I doing wrong? Please Help!

 

 

My Code:

 

 

    
    Imports System    
    Imports System.Net    
    Imports System.Security    
    Imports System.Security.Cryptography.X509Certificates    
    Public Class Form1    
        Inherits System.Windows.Forms.Form    
    Region " Windows Form Designer generated code "....    
        
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load    
            System.Net.ServicePointManager.CertificatePolicy = New trustedCertificatePolicy    
        End Sub    
        Private Sub btnGetNodes_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GetNodes.Click    
            Dim myNode As New Node.ITCMLocalLBNode    
            Dim myCred As New System.Net.NetworkCredential    
            If Hostname.Text = "" Then    
                MsgBox("No Hostname Listed", MsgBoxStyle.Critical, "Error")    
                Exit Sub    
            End If    
            ' URL to BigIP    
            myNode.Url = "https://" & Hostname.Text & ":" & 443 & "/iControl/iControlPortal.cgi"    
            Debug.WriteLine(myNode.Url)    
            ' Turn on pre Auth?    
            myNode.PreAuthenticate = True    
            ' Credentials to connect (In Production we should use read only)    
            myCred.UserName = Username.Text    
            myCred.Password = Password.Text    
            ' Pass credentials to the BigIP    
            myNode.Credentials = myCred    
            ' Empty the NodeList    
            NodeList.Items.Clear()    
            ' Get List of Nodes    
            Dim myNodeDefs() As Node.ITCMCommonIPPortDefinition    
            myNodeDefs = myNode.get_node_server_list    
            Dim myNodeStat() As Integer    
            myNodeStat = myNode.get_state_ex(myNodeDefs)    
            Dim i As Integer    
            For i = 0 To myNodeDefs.Length    
                NodeList.Items.Add(myNodeDefs(i).address & ":" & myNodeDefs(i).port, Convert.ToBoolean(myNodeStat(i)))    
                Console.WriteLine(myNodeDefs(i).address)    
            Next    
        End Sub    
        Public Class trustedCertificatePolicy    
            Implements ICertificatePolicy    
            Public Function CheckValidationResult( _  
                ByVal srvPoint As System.Net.ServicePoint, _  
                ByVal certificate As System.Security.Cryptography.X509Certificates.X509Certificate, _  
                ByVal request As System.Net.WebRequest, _  
                ByVal certificateProblem As Integer _  
              ) As Boolean Implements System.Net.ICertificatePolicy.CheckValidationResult  
                Return True  
            End Function  
    
            Public Function CheckValidationResult( _ 
                ByVal srvPoint As System.Net.ServicePoint, _ 
                ByVal certificate As System.Security.Cryptography.X509Certificates.X509Certificate, _ 
                ByVal request As System.Net.WebRequest, _ 
                ByVal certificateProblem As Integer _ 
              ) As Boolean Implements System.Net.ICertificatePolicy.CheckValidationResult    
                Return True    
            End Function    
        End Class    
    End Class    
    

2 Replies

  • Excellent! Thanks for the follow up. I will send my video suggestions shortly.

     

     

    So you made the Star Wars comment. How was it?
  • Great, we'll be waiting for the suggestions.

     

     

    Star Wars III was excellent - by far the best one yet. A bit darker and more violent that the others but it really tied up all the loose ends in the series. We've got a digital theater here in Seattle and watching it in pure digital form (no scratches, etc) was just incredible. If you are a fan at all of that series, then you have to see this on the big screen.

     

     

    -Joe