1

I'm behind ISA Server Proxy and I need to call a web service. Given its wsdl I've created proxies (using Add Service Reference command) and have tried to call the service, but it raised an exception telling me that proxy authorization is required. After some research I've found a solution to my problem

            var webproxy = new WebProxy(new Uri("http://<address>:<port>").ToString(), true, new string[]
            {
            })
            {
                Credentials = networkCredentials,
                BypassProxyOnLocal = false
            };

        WebRequest.DefaultWebProxy = webproxy;

After this piece of code I'm able to call web service. But as I've read here by default DefaultWebProxy uses the same settings as set in IE. However WebRequest.DefaultWebProxy.Credentials is null and I'm unable to pass thru the proxy. Why?

Community
  • 1
  • 1
javros
  • 825
  • 10
  • 31

1 Answers1

0

I've was also same boat. The last answer on this post helped me.

How do I determine (elegantly) if proxy authentication is required in C# winforms app

Especially. //HACK: add proxy IWebProxy proxy = WebRequest.GetSystemWebProxy(); proxy.Credentials = System.Net.CredentialCache.DefaultCredentials; req.Proxy = proxy; req.PreAuthenticate = true; //HACK: end add proxy

coolcake
  • 2,917
  • 8
  • 42
  • 57