-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Default Proxy issues #25745
Comments
You should not need user & password in Uri. What version of .Net and OS is failing for you? |
If you simply want to use the default system proxy and need to pass default credentials to that proxy (because the proxy is an authenticated proxy) during HTTP requests, then do this: var handler = new HttpClientHandler();
handler.DefaultProxyCredentials = CredentialCache.DefaultCredentials;
var client = new HttpClient(handler);
// Now use 'client' to do requests. This assumes that you already have a default system proxy configured on the machine. I.e. on Windows machine you would set up the default system proxy via Internet Explorer settings using 'Automatic' settings or PAC file or explicit settings. For example: |
Also, putting username and password into the Uri itself is a deprecated concept and is ignored in the HTTP stacks of .NET Framework and .NET Core.
|
I'm also having proxy issues with MacOs. static void Main(string[] args)
{
HttpClientHandler handler = new HttpClientHandler();
var client = new HttpClient(handler);
string baseUrl = "http://www.bbc.com";
try
{
HttpResponseMessage res = client.GetAsync(baseUrl).Result;
if (res.IsSuccessStatusCode)
{
Console.WriteLine("Success");
}
else
{
Console.WriteLine("Failed");
}
}
catch (Exception e)
{
Console.WriteLine(e);
}
} This code doesn't respect proxy settings configured on MacOs. Is default proxy is not used by HttpClient or am I missing some configuration? I have also posted this on stackoverflow https://stackoverflow.com/questions/49653986/dotnet-core-httpclient-doesnt-respect-proxy-settings-on-mac |
On OSX You have to "export http_proxy http://proxy.server.com:3128" |
@IeuanWalker I think your questions about to enable default credentials use for the default system proxy have been answered above. So, we'll close this issue now. |
Default Proxy issues
Our organisation has a proxy and in previous versions on .NET (.net full framework), you can add the following to the web.config and the application will use your system's default proxy.
I have tried a lot of different options but just cant seem to get anything to work.
Any help would be greatly appreciated.
The text was updated successfully, but these errors were encountered: