473,322 Members | 1,307 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,322 software developers and data experts.

WebClient issue connection closed...

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:

string strURL = "http://www.microsoft.com"
WebClient aWebClient = new WebClient();
Byte[] aBA = aWebClient.DownloadData(strURL);
string strContent = Encoding.ASCII.GetString(aBA);

It fails with the error "The underlying connection was closed: unable
to connect to the remote server". Except for the code change
everything's the same. I'm aware of the KB stuff about proxy etc, but
there's no proxy here to worry about. The same behaviour is exhibited
at work and at home.

What's going on?

Cheers,
Gary
Nov 15 '05 #1
2 4649
Gary,

Are you running these two sections of code right after another, or are
you running them in different programs?

Obviously, there should be no difference, and I can not find any errors
with your code. I've tried it myself, and it works the same either way.
Can you give more details, and actual code if the example you gave was not
the real code?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Gary Short" <gs****@scotlandonline.co.uk> wrote in message
news:d3**************************@posting.google.c om...
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:

string strURL = "http://www.microsoft.com"
WebClient aWebClient = new WebClient();
Byte[] aBA = aWebClient.DownloadData(strURL);
string strContent = Encoding.ASCII.GetString(aBA);

It fails with the error "The underlying connection was closed: unable
to connect to the remote server". Except for the code change
everything's the same. I'm aware of the KB stuff about proxy etc, but
there's no proxy here to worry about. The same behaviour is exhibited
at work and at home.

What's going on?

Cheers,
Gary

Nov 15 '05 #2
Hello Nicholas,

Thanks for getting back to me. I believe the problem was to do with a
DNS server somewhere, though quite why it would manifest itself in
quite this manner is beyond me. I received an emial from my ISP
telling me there were DNS problems and sure enough today it's working
fine.

I'm still a little confused as to what the problem was, but at least
it's sorted now.

Thanks again for your input.

Cheers,
Gary
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in message news:<#h**************@TK2MSFTNGP10.phx.gbl>...
Gary,

Are you running these two sections of code right after another, or are
you running them in different programs?

Obviously, there should be no difference, and I can not find any errors
with your code. I've tried it myself, and it works the same either way.
Can you give more details, and actual code if the example you gave was not
the real code?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Gary Short" <gs****@scotlandonline.co.uk> wrote in message
news:d3**************************@posting.google.c om...
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:

string strURL = "http://www.microsoft.com"
WebClient aWebClient = new WebClient();
Byte[] aBA = aWebClient.DownloadData(strURL);
string strContent = Encoding.ASCII.GetString(aBA);

It fails with the error "The underlying connection was closed: unable
to connect to the remote server". Except for the code change
everything's the same. I'm aware of the KB stuff about proxy etc, but
there's no proxy here to worry about. The same behaviour is exhibited
at work and at home.

What's going on?

Cheers,
Gary

Nov 15 '05 #3

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

Similar topics

4
by: Justin Malloy | last post by:
I am using the System.Net.Webclient to try and download an XML file from a website but am receiving a HTTP protocol error when running the DownloadFile() sub routine. I did a HTTP trace using...
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()...
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: Kumar | last post by:
Hi all, I have the following code which uses WebClient.UploadValues myNameValueCollection.Add("Name", name) myNameValueCollection.Add("Age", age) .............. ............. Dim web As New...
7
by: Crirus | last post by:
Hi all! I use a webClient for requesting data from a server of mine. Should I worry about long ammount of data sent by server in the client side? Or, another way, should I send some kind of a...
1
by: matt | last post by:
hello, i am using a .NET 1.1 winform to perform webrequests via the System.Net.WebClient class (not a webservice, actually). It uploads values via a POST command & a URL, then receives the html...
1
by: vin.dor | last post by:
Dear All, I am using WebClient in my Visual Studio .Net 2003 project to download an image from the Internet. The following is my function: C# Code: public static bool downloadFile(string...
0
by: Rlake | last post by:
I am having trouble with my ADSL router, so am writing a simple app to 'click' the Reset button on its HTML configuration page for me whenever the connection drops out. I am trying to send a...
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.