I am talking to a webservice via a webrequest, I am behind a proxy that requires authentication.
What I would like to do is piggyback off the IE / Control Panel settings but I am having some difficulty…
if I do this, all is fine…
WebProxy proxy = new WebProxy(@"http://my.secret.address:8080");
proxy.Credentials = CredentialCache.DefaultNetworkCredentials;
WebRequest.DefaultWebProxy = proxy;
What I really want to do is simply this…
WebRequest.DefaultWebProxy = WebRequest.GetSystemWebProxy(); // Subsequent webrequest call Fails with a "Unable to connect to remote server" error message.
I really do not want to have to specify the proxy address, as it is not the same for all users. In fact some won’t even be behind a proxy. I just want to use the IE /Control Panel settings. Oh I am using Vista in case that makes a difference, and also the proxy settings in th econtrol panel / IE are using an auto config file (proxy.pac file)
Edit: So succinctly. How do I use the IE / Control Panel proxy settings. Including when using an Auto configuration file ?
Further Edit:
Ok, I think I have narrowed down the problem to the Auto Config thing. If I have the proxy address explicitly set in the dialog I can use the .GetSystemWebProxy() settings…but (like in my case) if I am using an Auto Config pac file, I have this issue.
sigh, well after more investigation I fixed this problem just to get a different one….
The fix is to create the WebProxy with the .pac Uri
Easy peasy…
So now I am getting through the proxy, but the Proxy server is messing with my request and the web service is barffing. (Note it doesn’t do it if I am specific about the proxy address….sigh)