GlobalProxySelection.Select Właściwość

Definicja

Pobiera lub ustawia globalny serwer proxy 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; }
member this.Select : System.Net.IWebProxy with get, set
Public Shared Property Select As IWebProxy

Wartość właściwości

IWebProxy

To IWebProxy każde wywołanie do GetResponse() użycia.

Wyjątki

Wartość określona dla operacji zestawu to null.

Obiekt wywołujący nie ma uprawnień do żądanej operacji.

Przykłady

Poniższy przykład kodu ustawia Select właściwość na pusty serwer proxy.

#using <System.dll>

using namespace System;
using namespace System::Net;
using namespace System::IO;
int main()
{
   
   // Create a request for the Web page at www.contoso.com.
   WebRequest^ request = WebRequest::Create( L"http://www.contoso.com" );
   
   // This application doesn't want they proxy to be used so it sets
   // the global proxy to an empy proxy.
   IWebProxy^ myProxy = GlobalProxySelection::GetEmptyWebProxy();
   
   // Get the response.
   WebResponse^ response = request->GetResponse();
   
   // Display the response to the console.
   Stream^ stream = response->GetResponseStream();
   StreamReader^ reader = gcnew StreamReader( stream );
   Console::WriteLine( reader->ReadToEnd() );
   
   // Clean up.
   reader->Close();
   stream->Close();
   response->Close();
   return 0;
}
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();
        }
    }
}

Uwagi

Właściwość Select ustawia serwer proxy, którego używają wszystkie WebRequest wystąpienia, jeśli żądanie obsługuje serwery proxy, a żaden serwer proxy nie jest jawnie ustawiany przy użyciu Proxy właściwości . Serwery proxy są obecnie obsługiwane przez FtpWebRequest elementy i HttpWebRequest.

Dotyczy