GlobalProxySelection.GetEmptyWebProxy メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
空白のプロキシ インスタンスを返します。
public:
static System::Net::IWebProxy ^ GetEmptyWebProxy();
public static System.Net.IWebProxy GetEmptyWebProxy();
static member GetEmptyWebProxy : unit -> System.Net.IWebProxy
Public Shared Function GetEmptyWebProxy () As IWebProxy
戻り値
情報が格納されていない IWebProxy。
例
次のコード例では、プロキシを WebRequest 使用しないインスタンスを作成します。
using System;
using System.Net;
using System.IO;
namespace Examples.Http
{
public class TestGlobalProxySelection
{
public static void Main()
{
// Create a request for the Web page at www.contoso.com.
WebRequest request = WebRequest.Create("http://www.contoso.com");
// This application doesn't want the proxy to be used so it sets
// the global proxy to an empty proxy.
IWebProxy myProxy = GlobalProxySelection.GetEmptyWebProxy();
GlobalProxySelection.Select = myProxy;
// Get the response.
WebResponse response = request.GetResponse();
// Display the response to the console.
Stream stream = response.GetResponseStream();
StreamReader reader = new StreamReader(stream);
Console.WriteLine(reader.ReadToEnd());
// Clean up.
reader.Close();
stream.Close();
response.Close();
}
}
}
注釈
メソッドは GetEmptyWebProxy 、インターネット リソースへのアクセスにプロキシが使用されていないことを示す空 IWebProxy のインスタンスを返します。
メソッドをGetEmptyWebProxy
呼び出す代わりに、 プロパティなどのWebClient.Proxyメンバーに割り当てることができますnull
。このプロパティは、オブジェクトの代わりにリモート サーバーと通信するプロキシをWebClient指定します。