-
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
HttpClient.DefaultProxy should respect IE proxy changes #46910
Comments
Tagging subscribers to this area: @dotnet/ncl Issue DetailsEnv: Windows server 2008 R2 SP1 In .netfx, this API work fine, if turn on Fiddler capturing, it capturing. How get the IE proxy settings? Please help.
|
I think this is really a mistake:
|
I am curious why that detection does not work on your machine. Are you able to enable logging in your environment, or even better, debug into the proxy initialization?
|
Thanks for your response. The another problem is the // the right way:
DateTime GetNowTime() => DateTime.Now;
// your way
DateTime _now = DateTime.Now;
DateTime GetNowTime() => _now; Finnally, i don't want to expand discussion of |
We do not have ability to get current IE settings in .NET Core. .NET Framework watches for registry changes that signal change in proxy settings (reg key On .NET Core we read proxy settings only once at first use, by querying WinHttp in WinInetProxyHelper - it is the same function that .NET Framework uses. I assume, we could implement similar registry change monitoring and refresh proxy info from WinHttp in such case (assuming it was not overridden by app/env variables). The key remaining question is: How much does it matter? Is it only developer scenario (Fiddler turned on and off during application execution), and how commonly is it needed? Or are there other scenarios that would benefit from this? |
This is really regrettable. Ofcourse not only developer scenario, many programs with network access capabilities usually provide an option called Use IE proxy or Use System proxy, and |
@ahdung I am sorry that you ran into this the hard way. Yes, it is some incompatibility with .NET Framework, which hit you by surprise. We wish we could be 100% compatible, but you can probably imagine that it is impossible task and we have to pick our battles and choose where to invest. To answer your concerns: The obsoletion of Regarding To make further progress, there are several separate "issues" raised here:
@ahdung did I miss any angle? From the list, which of the problems do you think is worth solving in .NET Core? |
@karelz My English is not good, I try to understand what you mean, please point out if there is any misunderstanding. Regarding Regarding Regarding "issues":
|
Absolutely. Happy to help. Let me know if some of my explanations are not clear.
It is already obsoleted. Old apps can use it. They will not get full functionality or high performance though.
I understand what you're saying. Given that Regarding your answers to "issues" 1-3: I am looking for real world scenarios. Cases you have hit where it matters. How important are those scenarios / cases and how common are they? |
Triage: We are ok to take a change with monitoring registry for IE proxy change and try to apply it. It is low pri for us though. |
@karelz I must say that this is a great news for me, high expectations, thank you for your understanding. |
@ahdung we do not plan to support direct access to IE proxy via new API. If part of your app decides to override it (incl. env. variables), then it is what will be set. |
@karelz I see. |
I think we're running into a similar issue. I'd like to explain our use case 🙂 When our company laptops are on the company network, they use a proxy. When they are off the company network, we're required to use our company VPN. However, now that people have started working from home, some people are doing this:
Disabling the VPN/proxy is against company rules, but it seems that people are doing it, and Our code looks as follows: Startup.cs services
.AddHttpClient<IExample, Example>(httpClient =>
{
httpClient.BaseAddress = new Uri(Configuration["..."], UriKind.Absolute);
})
.ConfigurePrimaryHttpMessageHandler(sp =>
{
return new HttpClientHandler()
{
UseProxy = true,
DefaultProxyCredentials = CredentialCache.DefaultCredentials
}
}); Example.cs public class Example
{
public Example(HttpClient httpClient)
{
_httpClient = httpClient ?? throw new ArgumentNullException(nameof(httpClient));
}
public async Task Test()
{
await _httpClient.GetAsync("http://example.com");
}
} When I do the following:
If I log off the VPN, disable the proxy, and then start the app, everything works fine. Not sure if this use case is worth supporting, but thought I'd mention it 🙂 I think a more common use case might be that the company updates the proxy's |
this make sense to me. I'm wondering if we could do refresh of proxy setting when we fail to connect to proxy. any thoughts on this @geoffkizer? (we already have some re-try mechanism inside of the Windows proxy, we would just need mechanism to kick another lookup) |
Actually looking at #63788, since we already hook for NetworkChange, that may work as well as trigger to re-check proxy setting. |
@karelz Thank you. This behavior is like a bug. The .NET Core application can not handle the system web proxy changed. The step:
And then we will find the .NET Core application can not connect the network. |
Closing as a dupe of #95252, see #95252 (comment) Optimistically planned for 9.0. |
Env: Windows server 2008 R2 SP1
In .netfx, this API work fine, if turn on Fiddler capturing, it capturing.
But in .netcore (3.1+), this API always return HttpNoProxy, no longer respect the IE proxy settings.
How get the IE proxy settings? Please help.
The text was updated successfully, but these errors were encountered: