This documentation is archived and is not being maintained.

WebProxy.IsBypassed Method

Indicates whether to use the proxy server for the specified host.

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

'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 final boolean IsBypassed (
	Uri host
)
public final function IsBypassed (
	host : Uri
) : boolean
Not applicable.

Parameters

host

The Uri instance of the host to check for proxy use.

Return Value

true if the proxy server should not be used for host; otherwise, false.

The IsBypassed method is used to determine whether to bypass the proxy server when accessing an Internet resource.

The BypassProxyOnLocal and BypassList properties control the return value of the IsBypassed method.

IsBypassed returns true under any of the following conditions:

  • If BypassProxyOnLocal is true and host is a local URI. Local requests are identified by the lack of a period (.) in the URI, as in "http://webserver/".

  • If host matches a regular expression in BypassList.

  • If Address is a null reference (Nothing in Visual Basic).

All other conditions return false.

The following code example creates a WebProxy object and calls this method to check whether the bypass list is properly set.

No code example is currently available or this language may not be supported.
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("http://www.Contoso.com")))) {
        Console.WriteLine("Bypass not working!");
        return null;
    }
    else {
        Console.WriteLine("Bypass is working.");
        return proxy;
    }
} //CreateProxyAndCheckBypass

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

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0
Show: