'NO_PROXY ignored by .NET Core 3.0 on Windows

We are trying to get proxy functionality to work in a .NET Core 3.0 (or 3.1) app on Windows. What we find is that the HTTPS_PROXY and HTTP_PROXY variables are recognized and processed as expected, but the default proxy does not appear to honor the NO_PROXY variable. Here is sample code:

 HttpClient client = new HttpClient();
 IWebProxy myProxy = HttpClient.DefaultProxy;
 Uri target = new Uri(args[0]);
 Uri proxy = myProxy.GetProxy(target);
 Console.WriteLine($"Target proxy for {target} is {proxy} {myProxy.IsBypassed(target)}");

If I run this from PowerShell as such:

if (-not $env:path.Contains('c:\data\src')) {
    $env:path = "$env:Path;C:\data\src\Local\DefaultProxy\bin\Debug\netcoreapp3.0"
}
$env:HTTPS_PROXY = 'http://10.11.10.10'
$env:NO_PROXY = '*'
DefaultProxy https://www.contoso.com

I get:

Target proxy for https://www.contoso.com/ is http://10.11.10.10/ False

I expect to get blank and true.

What should I change so that I can use NO_PROXY to exclude domains from the default proxy?



Solution 1:[1]

there is never a "standard" in the no_proxy. In Linux, most applications recognized it as lower_case. Sure, in Windows, it is always case-insensitive. But when it comes to wildcard matching or regex matching, there is no standard at all. Each application works its own way as it see fit, for no_proxy.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ben L