Using a Web Proxy in .Net 2003

.Net is kind enough to pull your current Internet Explorer proxy settings by default.  But it leaves out one important option – the ‘Use Windows integrated authentication’ checkbox.  If your proxy server requires NTLM authentication, and you’re relying on this feature of IE for it, then your .Net 1.1 apps will not work.  Any web or web service requests will return a ‘Proxy authentication required’ error.

There are 2 options at this point.  You can tell your web request to completely ignore proxy settings and access the address directly:

webService.Proxy = System.Net.GlobalProxySelection.GetEmptyWebProxy

Or you can specify your own proxy server and credentials:

Dim authTest As New System.Net.NetworkCredential(“username”, “password”)
Dim proxTest As New System.Net.WebProxy(“http://192.168.0.4:3128”)
proxTest.Credentials = authTest
webService.Proxy = proxTest

I haven’t found any way (yet) with .Net 1.1 to have it use the credentials of the currently logged in user.

Edit: Nevermind, I’m an idiot.   You can use System.Net.CredentialCache.DefaultCredentials for the security settings of the current user.