473,830 Members | 2,133 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.EventArg s e)

{

NameValueCollec tion values = new NameValueCollec tion();

values.Add("ppt pdisconnect","t rue");

string got =
UploadValuesToS ecureWebsite("h ttp://192.168.0.1/","admin","**** ***","post",v
alues);

}

public string UploadValuesToS ecureWebsite(st ring URL, string Username,
string Password, string Method, NameValueCollec tion values)

{

WebClient myWebClient = new WebClient();

NetworkCredenti al trust = new NetworkCredenti al(Username,Pas sword);

myWebClient.Cre dentials = trust;

byte[] Response = myWebClient.Upl oadValues(URL, Method, values);

string result = Encoding.ASCII. GetString(Respo nse);

return result;

}

Regards, Max - I hope my English was understandable, or even good ;-)
PS: Here, the details about the failure:

at System.Net.Conn ectStream.Begin Read(Byte[] buffer, Int32 offset, Int32
size, AsyncCallback callback, Object state)
at System.Net.Conn ectStream.Read( Byte[] buffer, Int32 offset, Int32 size)
at System.Net.WebC lient.ResponseA sBytes(WebRespo nse response)
at System.Net.WebC lient.UploadVal ues(String address, String method,
NameValueCollec tion data)
Nov 16 '05 #1
2 4289
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.innerexceptio n.message if the
innerexception is set.

"Max Gattringer" <ma***********@ msn.com> wrote in message
news:%2******** ********@tk2msf tngp13.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.EventArg s e)

{

NameValueCollec tion values = new NameValueCollec tion();

values.Add("ppt pdisconnect","t rue");

string got =
UploadValuesToS ecureWebsite("h ttp://192.168.0.1/","admin","**** ***","post",v alues);

}

public string UploadValuesToS ecureWebsite(st ring URL, string Username,
string Password, string Method, NameValueCollec tion values)

{

WebClient myWebClient = new WebClient();

NetworkCredenti al trust = new NetworkCredenti al(Username,Pas sword);

myWebClient.Cre dentials = trust;

byte[] Response = myWebClient.Upl oadValues(URL, Method, values);

string result = Encoding.ASCII. GetString(Respo nse);

return result;

}

Regards, Max - I hope my English was understandable, or even good ;-)
PS: Here, the details about the failure:

at System.Net.Conn ectStream.Begin Read(Byte[] buffer, Int32 offset, Int32
size, AsyncCallback callback, Object state)
at System.Net.Conn ectStream.Read( Byte[] buffer, Int32 offset, Int32 size) at System.Net.WebC lient.ResponseA sBytes(WebRespo nse response)
at System.Net.WebC lient.UploadVal ues(String address, String method,
NameValueCollec tion 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
1998
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() System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult) System.Net.HttpWebRequest.GetResponse() System.Net.WebClient.OpenRead(String address)
11
942
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 during a webclient request" .._Hresult = "-2146233079" .._COMPlusExceptionCode ="-532459699" Sorry I don't have the whole error, but this seems to be the only pertinent
2
4686
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 = aWebClient.DownloadData("http://www.microsoft.com"); string strContent = Encoding.ASCII.GetString(aBA); Everything works as expected. However, when I run the following code:
2
5371
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
13308
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 = "application/octet-stream"; Response.AppendHeader("Content-Disposition", "attachment;filename=" + fileID.ToString() + ".pdf");
0
1446
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() System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult) System.Net.HttpWebRequest.GetResponse() System.Net.WebClient.OpenRead(String address)
3
7593
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 a form and the values, test.asp reports them fine. ---------------------------- Dim thePost As String = "Variable1=Value1&Variable2=Value2&Variable3=Value3" Dim thePage As Byte() Dim MyWebClient As New System.Net.WebClient
6
22110
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 (setup.exe). I then use WebClient.DownloadFileAsync (.NET 2.0 Pro.) and all downloads well including progress bar indicator, bytes received, etc... Here is the problem: When I replace the file (setup.exe), with a different, larger file, it still...
4
7787
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. The problem is, certain cookies need to be set, and the only way of doing that is not letting the WebClient automatically go on to the next GET in the background--I need to do it manually. I'm wondering if this has something to do with the...
1
6501
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 <authentication mode="Windows" /> and set up IIS to not allow anonymous access. My browser is set up to auto detect the proxy server, so IE/Firefox can access outside pages, so I added code to auto-detect the proxy server.
0
9781
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9641
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10769
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10477
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10522
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10197
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9310
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5777
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4408
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.