473,372 Members | 900 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,372 software developers and data experts.

WebClient Problem

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)
Nov 16 '05 #1
2 4256
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" <ma***********@msn.com> wrote in message
news:%2****************@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)

Nov 16 '05 #2
Hi, just found my failure: All my methods completely okay, but i always
used http://192.168.0.1, but actually i had to use
192.168.0.1/status.cqi! Shame on me, but at least it works now..
Furthermore there is difference between using
?pptpdisconnect=true/disconnect or whatsover - any value...

Regards, Max
PS: Foolish failure isn't it ;-)

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Helen Abell | last post by:
Hi, I am trying to use a .Net WebClient object to read data from a url, but I am getting the following error: System.Net.HttpWebRequest.CheckFinalStatus()...
11
by: ptass | last post by:
Hi I've installed win2k3 sp1 on a machine where an openRead on any given file was previously working. After installation, I get a webException as follows... ..message "An exception occurred...
2
by: Gary Short | last post by:
Hello group, I was wondering if anyone here could help me with an odd WebClient problem. When I run the following code: WebClient aWebClient = new WebClient(); Byte aBA =...
2
by: xzzy | last post by:
I have .net 1.1 c# . . . . . using System.Net only lists sockets what do I need to do to be able to do: using System.Net.WebClient;
6
by: A.M-SG | last post by:
Hi, I have an aspx page at the web server that provides PDF documents for smart client applications. Here is the code in aspx page that defines content type: Response.ContentType =...
0
by: Helen | last post by:
Hi, I am trying to use a .Net WebClient object to read data from a url, but I am getting the following error: System.Net.HttpWebRequest.CheckFinalStatus()...
3
by: Manuel | last post by:
I have an asp page ("test.asp") that presents the data it receives from a post.When I try the following code, test.asp doesn't return the values (supposedly) posted to it. If I make a web page with...
6
by: Giovanni | last post by:
Hi Guys, Really strange problem I am experiencing... I have setup a virtual directory with Read Only permissions on an ISA/IIS server (SBS 2003). In that virt. dir., I placed 1 file...
4
by: Lehel Kovach | last post by:
I'm having a problem with the WebClient object. When I post data to certain sites, it will receive a command from the webserver (object moved) and continue to the next link by downloading that. ...
1
by: Mad Scientist Jr | last post by:
For some reason I can't get a WebClient to access an outside URL from behind our firewall. The code works when it runs outside the firewall. I turned on windows authentication in the web.config...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.