CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums




Can Reply:  No Members Can Edit: No Online: Yes
Zone: > NEWSGROUP > Asp.Net Forum > visual_studio.visual_studio_2005 Tags:
Item Type: NewsGroup Date Entered: 10/20/2005 4:04:39 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
NR
XPoints: N/A Replies: 1 Views: 108 Favorited: 0 Favorite
2 Items, 1 Pages 1 |< << Go >> >|
Jspohn
Asp.Net User
Using WebClient to download a file with a Proxy Server10/20/2005 4:04:39 PM

0

I have coded a simple program to use a WebClient to download a series of files for me.  However, I am currently behind a proxy server that is NOT automatic detection.

I keep getting an exception that says the Proxy Server Requires Authentication.  How can I pass this information into the object to complete the request?
Thanks.
Jerry
Spohn Software
www.spohnsoftware.com
USFbobFL
Asp.Net User
Re: Using WebClient to download a file with a Proxy Server12/21/2005 10:42:16 AM

0

Wow, no replies.  Well, I don't have the answer yet... I'm looking for it as are you (still?).
I can run this at home (no proxy) with no problems.  At work, I must go through a proxy.
My IE setting are configured to use the proxy AND I have the Microsoft Firewall Client installed and configured to the same proxy. Still, the (407) Proxy Authentication Required exception is raised.
Try to set WebClient.Proxy to a value (don't try a string value... it wants a System.Net.Iwebproxy), but System.Net.IwebProxy is not in intellisense.  However, there is a System.Net.WebProxy

OK, so I just solved it.  See code in red, added to address proxy authtication.

Imports System.Net

Public Class Form1

Public Function FTPdnld(ByVal lsSrcURI As String, ByVal lsTargetFile As String) As Boolean
  
Dim lbRetVal As Boolean = False
  
Dim wc As New WebClient
  Dim wp as new WebProxy
  wp.UseDefaultCredentials = True

  
Try
     wc.Proxy = wp
      
wc.DownloadFile(lsSrcURI, lsTargetFile)
       MsgBox(
"file " & lsSrcURI & "downloaded to " & lsTargetFile, MsgBoxStyle.Information)
      lbRetVal =
True
  
Catch ex As Exception
     
MsgBox("download failed: " & ex.Message)
End Try
wc.Dispose()
Return lbRetVal
End Function

End Class

2 Items, 1 Pages 1 |< << Go >> >|


Free Download:




   
  Privacy | Contact Us
All Times Are GMT