IWebProxy.IsBypassed(Uri) メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
指定したホストでプロキシを使用しないことを示します。
public:
bool IsBypassed(Uri ^ host);
public bool IsBypassed(Uri host);
abstract member IsBypassed : Uri -> bool
Public Function IsBypassed (host As Uri) As Boolean
パラメーター
戻り値
host
でプロキシ サーバーを使用しない場合は true
。それ以外の場合は false
。
例
次の例では、 プロパティを IsBypassed 使用して、指定したホストにプロキシ サーバーを使用するかどうかを判断します。
WebProxy_Interface webProxy_Interface = new WebProxy_Interface(new Uri("http://proxy.example.com"));
webProxy_Interface.Credentials = new NetworkCredential("myusername", "mypassword");
Uri testUri = new Uri("http://www.contoso.com");
// Determine whether the Web proxy can be bypassed for the site "http://www.contoso.com".
if(webProxy_Interface.IsBypassed(testUri))
{
Console.WriteLine("Web Proxy is by passed");
}
else
{
Uri? webProxyServer = webProxy_Interface.GetProxy(testUri);
// In general, we wouldn't expect the condition (`webProxyServer! == testUri`) true here, if IsBypassed returns `false`.
// However, technically our interface can allow that.
if (webProxyServer is null || webProxyServer! == testUri)
{
Console.WriteLine("Web proxy is bypassed");
}
else
{
Console.WriteLine("Web proxy is not bypassed");
Console.WriteLine($"The web proxy is: {webProxyServer!}");
}
}
Public Shared Sub Main()
Dim webProxy_Interface As New WebProxy_Interface(New Uri("http://proxy.example.com"))
webProxy_Interface.Credentials = New NetworkCredential("myusername", "mypassword")
Console.WriteLine("The web proxy is : {0}", webProxy_Interface.GetProxy(New Uri("http://www.contoso.com")))
'Determine whether the Web proxy can be bypassed for the site "http://www.contoso.com".
console.writeline("For the Uri http://www.contoso.com , the ")
If webProxy_Interface.IsBypassed(New Uri("http://www.contoso.com")) Then
Console.WriteLine("webproxy is by passed")
Else
Console.WriteLine("webproxy is not bypassed")
End If
End Sub
注釈
メソッドは IsBypassed 、 パラメーターで指定された host
ホストにプロキシ サーバーを使用してアクセスするかどうかを示します。 が 返されたtrue
場合IsBypassed、プロキシはホストに接続するために使用されず、要求はサーバーに直接渡されます。 からIsBypassed取得false
しても、URI がプロキシされる保証はありません。これを判断するには、 メソッドをGetProxy呼び出す必要があります。