Re: WebClient Problem

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Richard Brown (nospam_at_stopspamnow.org)
Date: 08/09/04


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)
>
>



Relevant Pages

  • Re: Data from web site
    ... You can then parse out the info from the returned string. ... Dim objShell As Object, objShellWindows As Object, o As Object ... >> I am trying to get some data from a web site. ...
    (microsoft.public.excel.programming)
  • Re: How to get user id guid
    ... string PrintName ... int nSize = translatedName.Capacity; ... My web site is using Integrated Windows authentication with Digest ...
    (microsoft.public.dotnet.security)
  • RE: Conflicts with multiple picture library webpart on the same page
    ... except the first one the "Thumbnail" column of the rest of the pic lib ... the page to return to your Web site. ... Exception Details: System.Runtime.InteropServices.COMException: Item does ... bstrUrl, String bstrListName, String bstrHtmlFormName, Int32 lFormType, ...
    (microsoft.public.sharepoint.portalserver.development)
  • Re: Long MsgBox -- need to display in 2 paragraphs
    ... I need to do a search of a string inside the value of a database... ... MsgBox Err.Description ... Word MVP web site http://word.mvps.org ...
    (microsoft.public.word.vba.general)
  • Re: How do I encypt a set of data so that I can post it to a web page
    ... My understanding was that in order to POST data to a web site from a VB app, ... encrypt/decrypt part that I can't get my head round. ... Make sure your encrypted string is WebSafe ... WebSafe form. ...
    (microsoft.public.vb.general.discussion)