WebProxy.GetProxy(Uri) Yöntem

Tanım

İstek için prxied URI'sini döndürür.

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

Parametreler

destination
Uri

Uri İstenen İnternet kaynağının örneği.

Döndürülenler

Uri

Uri Kaynak atlama listesindeyse İnternet kaynağının örneği; aksi takdirde ara Uri sunucu örneği.

Uygulamalar

Özel durumlar

destination parametresidirnull.

Örnekler

Aşağıdaki kod örneği bir WebProxy nesne oluşturur ve bir kaynak için seçilen ara sunucuyu almak için bu yöntemi çağırır.

// 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.
void CheckAutoGlobalProxyForRequest( Uri^ resource )
{
   WebProxy^ proxy = gcnew 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, resourceProxy );
   }
}
// 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());
    }
}

Açıklamalar

yöntemi, GetProxy örneğin İnternet kaynağına erişmek için kullandığı URI'yi HttpClient döndürür.

GetProxydestination yöntemini kullanarak içeriğini BypassListile karşılaştırırIsBypassed. döndürürse IsBypassedtrue, GetProxy döndürür destination ve HttpClient örnek proxy sunucusunu kullanmaz.

içinde BypassListHttpClient değilsedestination, örnek proxy sunucusunu kullanır ve Address özelliği döndürülür.

Şunlara uygulanır