469,645 Members | 1,188 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,645 developers. It's quick & easy.

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 4423
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Justin Malloy | last post: by
reply views Thread by Helen Abell | last post: by
reply views Thread by Kumar | last post: by
7 posts views Thread by Crirus | last post: by
1 post views Thread by vin.dor | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.