WebProxy.GetProxy(Uri) メソッド
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
要求に対するプロキシの 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
インターネット リソースがバイパス一覧に含まれている場合は、そのリソースの 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 、インスタンスが HttpClient インターネット リソースへのアクセスに使用する URI を返します。
GetProxy は destination
、 メソッドを使用して の BypassList内容と比較します IsBypassed 。 が を返す GetProxytrue
場合IsBypassedは がdestination
返され、HttpClientインスタンスはプロキシ サーバーを使用しません。
が でないBypassList場合destination
、インスタンスはHttpClientプロキシ サーバーを使用し、 Address プロパティが返されます。
製品 | バージョン |
---|---|
.NET | Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0, 2.1 |
.NET に関するフィードバック
.NET はオープンソース プロジェクトです。 フィードバックを提供するにはリンクを選択します。