Freigeben über


WebProxy.IsBypassed-Methode

Gibt an, ob der Proxyserver für den angegebenen Host verwendet werden soll.

Namespace: System.Net
Assembly: System (in system.dll)

Syntax

'Declaration
Public Function IsBypassed ( _
    host As Uri _
) As Boolean
'Usage
Dim instance As WebProxy
Dim host As Uri
Dim returnValue As Boolean

returnValue = instance.IsBypassed(host)
public bool IsBypassed (
    Uri host
)
public:
virtual bool IsBypassed (
    Uri^ host
) sealed
public final boolean IsBypassed (
    Uri host
)
public final function IsBypassed (
    host : Uri
) : boolean

Parameter

  • host
    Die Uri-Instanz des Hosts, der auf eine Proxyverwendung überprüft werden soll.

Rückgabewert

true, wenn der Proxyserver nicht für host verwendet werden soll, andernfalls false.

Hinweise

Die IsBypassed-Methode wird verwendet, um zu bestimmen, ob der Proxyserver beim Zugriff auf eine Internetressource umgangen werden soll.

Die BypassProxyOnLocal-Eigenschaft und die BypassList-Eigenschaft steuern den Rückgabewert der IsBypassed-Methode.

IsBypassed gibt unter den folgenden Bedingungen true zurück:

  • Wenn BypassProxyOnLocal true und host ein lokaler URI ist. Lokale Anforderungen werden dadurch gekennzeichnet, dass im URI kein Punkt (.) vorhanden ist, z. B. "http://Webserver/".

  • Wenn host mit einem regulären Ausdruck in BypassList übereinstimmt.

  • Wenn die Address-Eigenschaft NULL (Nothing in Visual Basic) ist.

Alle anderen Bedingungen geben false zurück.

Beispiel

Im folgenden Codebeispiel wird ein WebProxy-Objekt erstellt und diese Methode aufgerufen, um zu überprüfen, ob die Umgehungsliste ordnungsgemäß festgelegt ist.

public static WebProxy CreateProxyAndCheckBypass(bool bypassLocal)
{
    // Do not use the proxy server for Contoso.com URIs.
    string[] bypassList = new string[]{";*.Contoso.com"};
    WebProxy proxy =  new WebProxy("http://contoso", 
        bypassLocal, 
        bypassList);
        
    // Test the bypass list.
    if (!proxy.IsBypassed(new Uri("https://www.Contoso.com")))
    {
        Console.WriteLine("Bypass not working!");
        return null;
    } 
    else 
    {
        Console.WriteLine("Bypass is working.");
        return proxy;
    }
}
WebProxy^ CreateProxyAndCheckBypass( bool bypassLocal )
{
   // Do not use the proxy server for Contoso.com URIs.
   array<String^>^ bypassList = {";*.Contoso.com"};
   WebProxy^ proxy = gcnew WebProxy( "http://contoso",
      bypassLocal,
      bypassList );
   
   // Test the bypass list.
   if (  !proxy->IsBypassed( gcnew Uri( "https://www.Contoso.com" ) ) )
   {
      Console::WriteLine( "Bypass not working!" );
      return nullptr;
   }
   else
   {
      Console::WriteLine( "Bypass is working." );
      return proxy;
   }
}
public static WebProxy CreateProxyAndCheckBypass(boolean bypassLocal)
{
    // Do not use the proxy server for Contoso.com URIs.
    String bypassList[] = new String[] { ";*.Contoso.com" };
    WebProxy proxy = new WebProxy("http://contoso",
        bypassLocal, bypassList);
    // Test the bypass list.
    if (!(proxy.IsBypassed(new Uri("https://www.Contoso.com")))) {
        Console.WriteLine("Bypass not working!");
        return null;
    }
    else {
        Console.WriteLine("Bypass is working.");
        return proxy;
    }
} //CreateProxyAndCheckBypass

Plattformen

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

.NET Compact Framework

Unterstützt in: 2.0, 1.0

Siehe auch

Referenz

WebProxy-Klasse
WebProxy-Member
System.Net-Namespace