I have to set a proxy for the .net 5.0 application. I referred https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpclient.defaultproxy?view=net-5.0 which mentioned I can set HTTP_PROXY environment variable, which will be used for all the calls. Another option is I use HttpClientHandler to set the proxy for every client.
Is there a way I can set the proxy at the application level so that other applications don't get affected(this might happen in the case of setting the env variable)? And I don't want to set proxy at individual client level(HttpClient, SecretClient, etc).
HttpClientinstances use if no proxy is set explicitly in theHttpClientHandlerpassed through its constructor." So, when your application is initialized, set that static property to the proxy. It will then be set at the application level.