0

Is there any way to read the default proxy settings from within a UWP app (i.e., the values in HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings)?

Carl
  • 256
  • 5
  • 10
  • Won't the built-in HTTP client of UWP inherit the system proxy settings? – Seva Alekseyev May 09 '19 at 15:00
  • The app uses the built-in HTTP client for some purposes and the proxy settings work with that but a legacy library needs to have the proxy settings configured. So I need to be able to read them. – Carl May 09 '19 at 15:04
  • In general, they say it's possible but tricky: https://stackoverflow.com/questions/48899692/how-to-access-registry-key-in-a-uwp-app However, see if you can retrieve the proxy settings from the HTTP client itself. – Seva Alekseyev May 09 '19 at 15:06
  • I saw that one and it looks like a pain for such a simple thing. Also looked at getting from HttpClient but saw no means to do saw. Looked at the ProxyConfiguration class, which is not available and is documented as "not supported on Windows Phone", which I assume means UWP. – Carl May 09 '19 at 15:08
  • @Carl WindowsPhone != UWP. Windows.Foundation.UniversalApiContract is UWP. so this IS UWP class that not supported by Windows Phones – ad1Dima Jun 05 '19 at 09:30
  • Right, see the solution below that uses ProxyConfiguration. – Carl Jun 05 '19 at 15:23

1 Answers1

2

This works:

using Windows.Networking.Connectivity;


Uri uri = new Uri("http://www.example.com");               
ProxyConfiguration xx = await NetworkInformation.GetProxyConfigurationAsync(uri);
AVK
  • 3,893
  • 1
  • 22
  • 31
Carl
  • 256
  • 5
  • 10