Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Remoting / July 2006

Tip: Looking for answers? Try searching our database.

WebClient class is throwing exception

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Deepson Thomas - 03 Jul 2006 12:28 GMT
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\\"+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.

Signature

Deepson Thomas

Dave Sexton - 04 Jul 2006 22:27 GMT
Hi Deepson,

Try setting the WebClient.Proxy property to a new WebProxy instance
configured to meet your needs.

HTH

> Hi,
>
[quoted text clipped - 25 lines]
> When I am executing this code the file is created with 0 KB size but when
> the error comes it is deleted automatically.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.