WebProxy.GetProxy(Uri) 메서드

정의

요청에 대한 프록시된 URI를 반환합니다.

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

매개 변수

destination
Uri

요청된 인터넷 리소스의 Uri 인스턴스입니다.

반환

Uri

리소스가 사용 안 함 목록에 있으면 인터넷 리소스의 Uri 인스턴스이고, 그렇지 않으면 프록시의 Uri 인스턴스입니다.

구현

예외

destination 매개 변수가 null인 경우

예제

다음 코드 예제에서는 개체를 WebProxy 만들고 이 메서드를 호출하여 리소스에 대해 선택된 프록시를 가져옵니다.

// 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());
    }
}

설명

이 메서드는 GetProxy 인스턴스가 인터넷 리소스에 WebRequest 액세스하는 데 사용하는 URI를 반환합니다.

GetProxydestination 메서드를 사용하여 의 BypassList내용과 비교됩니다 IsBypassed . 반환true되면 IsBypassed 반환 GetProxy destination 되고 인스턴스는 WebRequest 프록시 서버를 사용하지 않습니다.

없는 BypassList경우 destination 인스턴스는 WebRequest 프록시 서버를 사용하고 속성이 Address 반환됩니다.

적용 대상