DotNet HttpClient.DefaultProxy Property not reading system settings on Win10

374 views Asked by At

The docs indicate, that the default Proxy-Setup for the HttpClient will be determined through the presence of environmental variables and/or the system wide proxy settings.

I set the proxy-auth credentials like this: setx http_proxy http://user:password@proxyIP:proxyPort/, and to be sure rebootet the system. Since the Windows proxy-settings dialog does not allow to set username and password, i included there the proxy address and port.

Now i try to read them back though the CredentialCache with my C# app.

However the CredentialCache.DefaultCredentials are still empty and the proxy blocks and responds with 407 exceptions. Which is correct, since i cannot pass the credentials.

How do i have to setup the username and password to be able to read them from the CredentialCache?

I would like to be able to go this way, since very old code, long time ago shipped to customers, using a WebRequest object together with this settings is able to go through.:

        UseDefaultCredentials = true;
        Proxy = WebRequest.GetSystemWebProxy();
        Proxy.Credentials = CredentialCache.DefaultCredentials;

Thats why i would like to also be able to write somethin to Windows that in turn gets read out of the Cache.

0

There are 0 answers