views:

410

answers:

1

Hi, Having some issues connecting to internet from an application where a customer is using a proxy server. The following code seems to work most other customers, including those that use proxies.

Dim wc As New WebClient
wc.UseDefaultCredentials = True
wc.Proxy = WebRequest.DefaultWebProxy

wc.Proxy.Credentials = wc.Credentials
Dim responseBytes As Byte() = wc.DownloadData("http://www.google.co.uk")

Error is:

System.Net.WebException: The remote server returned an error: (407) Proxy Authentication Required.

Previously this same way of connecting did work using their old proxy server, now it doesn't work. The customer has recently changed proxy server to one that uses NTLM authentication, so I guess this could be the issue.

Any ideas how I should be connecting any differently to above example?

Thanks, Mike G

+1  A: 

Without seeing what challenge the proxy is sending, it is difficult to say.

Use the techniques give here: http://ferozedaud.blogspot.com/2009/08/tracing-with-systemnet.html to generate a system.net logfile and see the challenge being sent. You can also post the logfile on a public site so that we can look at it.

Also, if your client is running the application on Windows7, then NTLM now defaults to 128bit encryption, and if the OS on the proxy does not support that, then the credentials wont even be sent to the proxy.

feroze