Explicitely specify Default user credentials for Proxy Server.

Some time ago I wrote post “Call Web Services through SQuid proxy server with authentication requested”  and hoped, that I will not have more problems with Squid web proxy server.
However the solution wasn’t sufficient for other site. I’ve tried a lot of things, started thread “Unable to access external web sites through Squid proxy server with required authentication.” and posted suggestion to Microsoft “Add ability to specify credentials to defaultProxy configuration element“.

But the best solution, that I found for the moment is  to create common function to set web proxy credentials and call it  for each Web Services call,HttpWebRequest call and replace  dataset.ReadXml(url)  with HttpWebRequest.GetRequest.
The function created expects up to 4 properties in appSettings section of Web.config
        <!–Web Proxy Credentials to use if useDefaultCredentials=”true” doesn’t help

    TODO move to separate ConfigurationSection, different from AppSettings

    <add key=”ProxyUserName” value=””/>

    <add key=”ProxyUserPassword” value=””/>

    <add key=”ProxyAuthenticationType” value=”Basic”/>

    <add key=”ProxyUserDomain” value=””/>

and to be called like the following for web services

        AWSECommerceService aws = new AWSECommerceService();



or for dataset.ReadXml


        IWebProxy proxyObject = CreateDefaultWebProxyWithCredentialsIfRequired(url);//WSClientHelper.

        if (proxyObject == null)




            Stream strm = GetResponseStream(url, proxyObject);//HttpWebRequestHelper.



The code of the SetDefaultWebProxyCredentialsIfRequired and other helper methods can be found here.