472,377 Members | 1,524 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,377 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 4576
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: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
1
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...
0
by: jack2019x | last post by:
hello, Is there code or static lib for hook swapchain present? I wanna hook dxgi swapchain present for dx11 and dx9.
0
DizelArs
by: DizelArs | last post by:
Hi all) Faced with a problem, element.click() event doesn't work in Safari browser. Tried various tricks like emulating touch event through a function: let clickEvent = new Event('click', {...

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.