WebProxy.GetProxy(Uri) Yöntem
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
İstek için proksid 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
Döndürülenler
Kaynak Uri atlama listesindeyse İnternet kaynağının örneği; aksi takdirde ara Uri sunucu örneği.
Uygulamalar
Özel durumlar
destination parametresi null'dir.
Örnekler
Aşağıdaki kod örneği bir WebProxy nesne oluşturur ve bir kaynak için seçilen proxy'yi 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.
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.
GetProxy
destination yöntemini kullanarak içindekilerle BypassListkarşılaştırırIsBypassed. döndürürse trueGetProxyIsBypassed, 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.