locked
The remote server returned an error: (503) Server Unavailable. RRS feed

  • Question

  • User-10248131 posted

    I want to mock up a button click event and passing a postdata using WebRequest, here is my code:

     

           Dim req As WebRequest = WebRequest.Create(site)
            'ctl00$TemplateBody$WebPartManager1$gwpciPublicRegistry$ciPublicRegistry$ResultsGrid$Sheet0$Input1$TextBox1
            Dim postData As String = "ctl00$TemplateBody$WebPartManager1$gwpciPublicRegistry$ciPublicRegistry$ResultsGrid$Sheet0$Input1$TextBox1=a"
    
            Dim send As Byte() = Encoding.[Default].GetBytes(postData)
            req.Method = "POST"
            req.ContentType = "application/x-www-form-urlencoded"
            req.ContentLength = send.Length
    
            Dim sout As Stream = req.GetRequestStream()
            sout.Write(send, 0, send.Length)
            sout.Flush()
            sout.Close()
    
            Dim res As WebResponse = req.GetResponse()

    The code returns error in the last line above:

    The remote server returned an error: (503) Server Unavailable.

    Here is the site's URL:

    http://ctcma.asicanada.net/CTCMAmbr/Public_Registry.aspx

    What I want to do is to mockup TextBox1 has a value of "a" and then the button is clicked.

    It would be appreciated if anyone can point out what's wrong with my code?

    Tuesday, March 31, 2015 8:47 AM

All replies