Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > WebClient Class throwing exception

Reply
Thread Tools

WebClient Class throwing exception

 
 
=?Utf-8?B?RGVlcHNvbiBUaG9tYXM=?=
Guest
Posts: n/a
 
      07-03-2006
Hi,

Iam trying to use WebClient class under system.net namespace to download
files from internet via http. For that iam using DownloadFile method. But
when ever iam trying to download any file iam getting the error “"The
underlying connection was closed: Unable to connect to the remote server”. My
computer is behind proxy. If iam trying to open this image via browser then
it is working.

I am pasting my code below.

string remoteUri = "http://www.deepson.com/images/";
string fileName = "uc2_large08.jpg", myStringWebResource = null;


WebClient myWebClient = new WebClient();
myStringWebResource = remoteUri + fileName;
Response.Write("<hr>Downloading File "+ fileName + " from "+
myStringWebResource );


myWebClient.DownloadFile(myStringWebResource,"C:\\ inetpub\\wwwroot\\TestWebApp\\Downloaded\\"+fileNa me);

Response.Write("<hr>Successfully Downloaded File "+ fileName +" from "+
myStringWebResource);

When I am executing this code the file is created with 0 KB size but when
the error comes it is deleted automatically.

--
Deepson Thomas
 
Reply With Quote
 
 
 
 
Henrik Stidsen
Guest
Posts: n/a
 
      07-03-2006

Deepson Thomas wrote:

> Iam trying to use WebClient class under system.net namespace to download
> files from internet via http. For that iam using DownloadFile method. But
> when ever iam trying to download any file iam getting the error ""The
> underlying connection was closed: Unable to connect to the remote server". My
> computer is behind proxy. If iam trying to open this image via browser then
> it is working.


Have you told the WebClient object to use the proxy ?

 
Reply With Quote
 
 
 
 
Joerg Jooss
Guest
Posts: n/a
 
      07-09-2006
Thus wrote Deepson,

> Hi,
>
> Iam trying to use WebClient class under system.net namespace to
> download files from internet via http. For that iam using DownloadFile
> method. But when ever iam trying to download any file iam getting the
> error "The underlying connection was closed: Unable to connect to the
> remote server. My computer is behind proxy. If iam trying to open
> this image via browser then it is working.
>
> I am pasting my code below.
>
> string remoteUri = "http://www.deepson.com/images/";
> string fileName = "uc2_large08.jpg", myStringWebResource = null;
> WebClient myWebClient = new WebClient();
> myStringWebResource = remoteUri + fileName;
> Response.Write("<hr>Downloading File "+ fileName + " from "+
> myStringWebResource );
> myWebClient.DownloadFile(myStringWebResource,"C:\\ inetpub\\wwwroot\\Te
> stWebApp\\Downloaded\\"+fileName);
>
> Response.Write("<hr>Successfully Downloaded File "+ fileName +"
> from "+ myStringWebResource);
>
> When I am executing this code the file is created with 0 KB size but
> when the error comes it is deleted automatically.


Are you using .NET 1.x or .NET 2.0?

Cheers,
--
Joerg Jooss
http://www.velocityreviews.com/forums/(E-Mail Removed)


 
Reply With Quote
 
saliegh saliegh is offline
Junior Member
Join Date: Jun 2007
Posts: 1
 
      06-25-2007
Hi All.

I am experiencing this same problem. I am using .net1.1, and not using a proxy.
The strange thing is that it works on my colleage's pc!

Thanks for the help in advance.
Saliegh
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
alias throwing exception: undefined method `send_mail' for class`HeartBeat' (NameError) Tristin Davis Ruby 1 06-15-2008 12:37 AM
System.IO.Directoryinfo throwing exception =?Utf-8?B?R2xlbm4gVmVuemtl?= ASP .Net 3 07-25-2005 09:49 PM
WebRequest.GetResponse() throwing exception (Internal Server error =?Utf-8?B?VGVycnk=?= ASP .Net 4 01-13-2005 10:25 PM
Problem of throwing an exception (System.Net.Sockets.OverlappedAsyncResult::CompletionPortCallback) VincentWong ASP .Net 1 12-29-2003 09:32 AM
Throwing Exception in a composite control KJ ASP .Net 5 07-25-2003 01:33 PM



Advertisments