Note

Access to this page requires authorization. You can try signing in or .

Access to this page requires authorization. You can try .

ProxyConfiguration Class

Definition

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Represents resolved proxy settings (proxy endpoints and direct-connect flag) for a specific target URI.

public ref class ProxyConfiguration sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class ProxyConfiguration final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class ProxyConfiguration
Public NotInheritable Class ProxyConfiguration
Inheritance
Object Platform::Object IInspectable ProxyConfiguration
Attributes

Windows requirements

Requirements Description
Device family
Windows 10 (introduced in 10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v1.0)
App capabilities
internetClient privateNetworkClientServer

Remarks

Retrieval

Call NetworkInformation.GetProxyConfigurationAsync with a target URI. The returned ProxyConfiguration instance applies only to that URI (host + scheme / port context).

Resolution scope

The uri parameter can include a hostname or IP plus port/service or protocol scheme. Resolution accounts for:

  • User/system proxy settings
  • Auto-config (PAC / WPAD) logic
  • Per-protocol overrides

Automatic handling

Note

Higher-level APIs (for example StreamSocket) automatically honor proxy settings; most apps do not need to manually resolve or apply proxies.

Properties

  • ProxyUris: Ordered proxy candidates (may be empty).
  • CanConnectDirectly: Indicates direct connection is permitted if no proxy succeeds.

Usage scenarios

Scenario Rationale
Diagnostics tooling Display active proxy chain and fallback logic
Custom HTTP stack / legacy interop Apply resolved proxy list manually
Policy validation Verify PAC script output or admin configuration
User assistance UI Show which proxy governs a failing connection

Handling results

  • Empty ProxyUris with CanConnectDirectly = true: connect directly.
  • Empty ProxyUris with CanConnectDirectly = false: treat as blocked (no route); surface appropriate error.
  • Multiple URIs: attempt in order; honor fail-over semantics (stop after first successful tunnel).

Best practices

  • Cache only for short durations; proxy auto-config can change during a session (network transitions).
  • Re-resolve after network status changes, sign-in events, or detection of repeated proxy failures.
  • Do not rewrite or reorder returned URIs; preserve precedence.

Failure / fallback

If connection attempts through all proxies fail:

  1. Re-resolve to detect configuration change.
  2. If unchanged and CanConnectDirectly is true, fall back to direct.
  3. Log proxy failure metrics (status codes / connection errors) for diagnostics.

Security considerations

  • Avoid exposing raw proxy credentials or PAC script internals in UI/logs.
  • Treat proxy URIs as potentially sensitive environment configuration.

For additional automatic proxy behavior discussion, see StreamSocket.

Properties

Name Description
CanConnectDirectly

Gets a value that indicates whether this configuration can connect directly.

ProxyUris

Gets a list of URIs for the proxies from the proxy configuration.

Applies to

See also


Feedback

Was this page helpful?