Re: WebClient Problem
From: Richard Brown (nospam_at_stopspamnow.org)
Date: 08/09/04
- Next message: Lubomir: "Resize a Form"
- Previous message: Sijin Joseph: "Re: do i need to add a reference to the assembly containing the input argument into a local method?"
- In reply to: Max Gattringer: "WebClient Problem"
- Next in thread: Max Gattringer: "Re: WebClient Problem"
- Reply: Max Gattringer: "Re: WebClient Problem"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 9 Aug 2004 00:10:22 -0700
I've worked A LOT with the web client, in fact, have a whole web site
scraping/auto form login/message board setup now.
It appears that the error you are getting is probably caused by the site
disconnecting you as the error is occuring in the 'response' section of the
connect methods.
I don’t know exactly, however, I am going to take a wild guess here.. Are
you sure that the "pptpdisconnect" variable is supposed to be True and not
"on" or blank? And is the server killing the connection because it is seeing
bad data coming across. Seeing that this is a "post" operation, most posted
webpages, using checkboxes, indicate the true, or checked state, with "on"
and not "true".
Try that and see. Also, it would help to know the exact exception that you
were getting... I know I probably have the book of every one you can
possibly get after writing this thing. Break the program when the exception
occurs, print the e.message, as well as the e.innerexception.message if the
innerexception is set.
"Max Gattringer" <maxgattringer@msn.com> wrote in message
news:%23ItDepIfEHA.3944@tk2msftngp13.phx.gbl...
> Hi,
>
> I've got a little problem with the WebClient, I always get a failure while
> debugging this code:
>
> private void menuItem2_Click(object sender, System.EventArgs e)
>
> {
>
> NameValueCollection values = new NameValueCollection();
>
> values.Add("pptpdisconnect","true");
>
> string got =
>
UploadValuesToSecureWebsite("http://192.168.0.1/","admin","*******","post",v
> alues);
>
> }
>
> public string UploadValuesToSecureWebsite(string URL, string Username,
> string Password, string Method, NameValueCollection values)
>
> {
>
> WebClient myWebClient = new WebClient();
>
> NetworkCredential trust = new NetworkCredential(Username,Password);
>
> myWebClient.Credentials = trust;
>
> byte[] Response = myWebClient.UploadValues(URL, Method, values);
>
> string result = Encoding.ASCII.GetString(Response);
>
> return result;
>
> }
>
> Regards, Max - I hope my English was understandable, or even good ;-)
> PS: Here, the details about the failure:
>
> at System.Net.ConnectStream.BeginRead(Byte[] buffer, Int32 offset, Int32
> size, AsyncCallback callback, Object state)
> at System.Net.ConnectStream.Read(Byte[] buffer, Int32 offset, Int32
size)
> at System.Net.WebClient.ResponseAsBytes(WebResponse response)
> at System.Net.WebClient.UploadValues(String address, String method,
> NameValueCollection data)
>
>
- Next message: Lubomir: "Resize a Form"
- Previous message: Sijin Joseph: "Re: do i need to add a reference to the assembly containing the input argument into a local method?"
- In reply to: Max Gattringer: "WebClient Problem"
- Next in thread: Max Gattringer: "Re: WebClient Problem"
- Reply: Max Gattringer: "Re: WebClient Problem"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|