WebProxy.GetProxy(Uri) Metódus
Definíció
Fontos
Egyes információk olyan, kiadás előtti termékekre vonatkoznak, amelyek a kiadásig még jelentősen módosulhatnak. A Microsoft nem vállal kifejezett vagy törvényi garanciát az itt megjelenő információért.
A kérelemhez megadott URI-t adja vissza.
public:
virtual Uri ^ GetProxy(Uri ^ destination);
public 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
Paraméterek
Válaszok
Az Uri internetes erőforrás példánya, ha az erőforrás szerepel a megkerülő listán, ellenkező esetben a Uri proxy példánya.
Megvalósítás
Kivételek
A destination paraméter a következő null: .
Példák
Az alábbi példakód létrehoz egy WebProxy objektumot, és meghívja ezt a metódust az erőforráshoz kiválasztott proxy lekéréséhez.
// 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());
}
}
Megjegyzések
A GetProxy metódus azt az URI-t adja vissza, amelyet a HttpClient példány az internetes erőforrás eléréséhez használ.
GetProxyösszehasonlítja destination a metódust használó BypassList tartalommalIsBypassed. Ha IsBypassed visszaadja truea függvényt, GetProxy akkor visszaadja destination , és a HttpClient példány nem használja a proxykiszolgálót.
Ha destination nincs benne BypassList, a példány a HttpClient proxykiszolgálót használja, és a Address tulajdonság vissza lesz adva.