GlobalProxySelection.Select プロパティ
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
グローバル HTTP プロキシを取得または設定します。
public:
static property System::Net::IWebProxy ^ Select { System::Net::IWebProxy ^ get(); void set(System::Net::IWebProxy ^ value); };
public static System.Net.IWebProxy Select { get; set; }
static member Select : System.Net.IWebProxy with get, set
Public Shared Property Select As IWebProxy
プロパティ値
IWebProxy へのすべての呼び出しが使用する GetResponse()。
例外
設定操作として指定した値が null
です。
呼び出し元には、要求された操作に対するアクセス許可がありません。
例
次のコード例では、 プロパティを Select 空のプロキシに設定します。
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();
}
}
}
注釈
プロパティは Select 、要求がプロキシをサポートし、 プロパティを使用してプロキシが明示的に設定されていない場合に、すべての WebRequest インスタンスが使用するプロキシを Proxy 設定します。 プロキシは現在、 と HttpWebRequestでFtpWebRequestサポートされています。