Click here to Skip to main content
15,897,334 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dim client As HttpWebRequest = CType(HttpWebRequest.Create(url), HttpWebRequest)

Dim wproxy As IWebProxy = WebRequest.GetSystemWebProxy


If (wproxy IsNot Nothing) Then
Dim myProxy As New WebProxy()
Dim newUri As New Uri(url)
myProxy.Address = newUri
myProxy.Credentials = New NetworkCredential("un", "pwd", "dom")
client.Proxy = wproxy
myProxy.Credentials = New NetworkCredential("un", "pwd", "dom")
Else
Console.WriteLine("Proxy is null; no proxy will be used")
End If

when running in the proxy environment i am get 407 authentication error... any suggestion. i haven't messed with .app config either. Do i have to make some changes to .app config file.
my config looks like this

<configuration>
<system.diagnostics>
<sources>
<!-- This section defines the logging configuration for My.Application.Log -->

<listeners> <add name="FileLog">
<!-- Uncomment the below section to write to the Application Event Log -->
<!--<add name="EventLog">-->


<switches>
<add name="DefaultSwitch" value="Information">

<sharedlisteners>
<add name="FileLog">
type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"
initializeData="FileLogWriter"/>
<!-- Uncomment the below section and replace APPLICATION_NAME with the name of your application to write to the Application Event Log -->
<!--<add name="EventLog" type="System.Diagnostics.EventLogTraceListener" initializedata="APPLICATION_NAME"> -->




Thanks in advance
Posted

1 solution

01 WebClient myWebClient = new WebClient();
02

03
// added lines
04
WebProxy proxyObj = new WebProxy("http://ipaddresshere:port");
05
proxyObj.Credentials = CredentialCache.DefaultCredentials;
06

07
myWebClient.Proxy = proxyObj;
08
// end added lines
09

10
// *EDIT* added below line in
11
myWebClient.DownloadFile("http:///File.aspx?id=100000", @"d:\xxx.doc");
 
Share this answer
 
Comments
surzzs 18-Oct-12 4:39am    
thanks for the answer but my concern will the defaultcredential work with https protocol

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900