WebProxy.GetProxy(Uri) Methode

Definitie

Retourneert de geproxiede URI voor een aanvraag.

public:
 virtual Uri ^ GetProxy(Uri ^ destination);
public Uri GetProxy(Uri destination);
abstract member GetProxy : Uri -> Uri
override this.GetProxy : Uri -> Uri
Public Function GetProxy (destination As Uri) As Uri

Parameters

destination
Uri

Het Uri exemplaar van de aangevraagde internetresource.

Retouren

Uri

Het Uri exemplaar van de internetresource, als de resource zich in de bypasslijst bevindt, anders het Uri exemplaar van de proxy.

Implementeringen

Uitzonderingen

De destination parameter is null.

Voorbeelden

In het volgende codevoorbeeld wordt een WebProxy object gemaakt en deze methode aangeroepen om de proxy op te halen die is geselecteerd voor een resource.

// The following method creates a WebProxy object that uses Internet Explorer's
// detected script if it is found in the registry; otherwise, it
// tries to use Web proxy auto-discovery to set the proxy used for
// the request.

public static void CheckAutoGlobalProxyForRequest(Uri resource)
{
    WebProxy proxy = new WebProxy();

    // Display the proxy's properties.
    DisplayProxyProperties(proxy);

    // See what proxy is used for the resource.
    Uri resourceProxy = proxy.GetProxy(resource);

    // Test to see whether a proxy was selected.
    if (resourceProxy == resource)
    {
        Console.WriteLine("No proxy for {0}", resource);
    }
    else
    {
        Console.WriteLine("Proxy for {0} is {1}", resource.OriginalString,
            resourceProxy.ToString());
    }
}

Opmerkingen

De GetProxy methode retourneert de URI die het HttpClient exemplaar gebruikt voor toegang tot de internetresource.

GetProxy vergelijkt destination met de inhoud van , met behulp van BypassListde IsBypassed methode. Als IsBypassed deze retourneert, GetProxy retourneert truedestination en het HttpClient exemplaar gebruikt de proxyserver niet.

Als destination dit niet BypassListhet geval is, gebruikt het HttpClient exemplaar de proxyserver en wordt de Address eigenschap geretourneerd.

Van toepassing op