2

I have the following site http://localhost/abc.htm which requires authorization

<form method="POST" action="/change">
<input type="hidden" name="node" value="12 4A 72 1" /><table>
    <tr>
        <td>
            <input type="submit" name="submit" value="On" />
        </td>
        <td>
            <input type="submit" name="submit" value="Off" />
        </td>
    </tr>
</table>
</form>

I'm trying to programatically post to this form as if I pressed the submit button "on". So far I've been able to authenticate and download the page using the WebClient class.

    Dim myCache As New CredentialCache()
    Dim req As New WebClient()
    Dim results As String
    myCache.Add(New Uri(URL), "Basic", New NetworkCredential(UserName, Password))
    req.Credentials = myCache
    results = UTF8.GetString(req.DownloadData(URL))

Now I'm trying to simulate pressing the button using UploadValues

    Dim mvc As New NameValueCollection
    mvc.Add("node", "12 4A 72 1")
    mvc.Add("submit", "On")
    req.UploadValues(URL, mvc)

However on the last line, I'm getting "The request was aborted: The request was canceled".

Any ideas as to what I'm doing wrong? Am I even using the correct set of classes for what I'm trying to accomplish?

WhiskerBiscuit
  • 4,795
  • 8
  • 62
  • 100

1 Answers1

0

This article might help: WebClient UploadFile errors

If you're getting TimeOuts then: http://geekswithblogs.net/SoftwareDoneRight/archive/2010/09/14/supporting-request-timeout-with-a-webclient.aspx

Community
  • 1
  • 1
web_bod
  • 5,728
  • 1
  • 17
  • 25