GlobalProxySelection.Select Eigenschaft

Definition

Ruft den globalen HTTP-Proxy ab oder legt diesen fest.

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

Eigenschaftswert

Ein IWebProxy, der bei jedem Aufruf von GetResponse() verwendet wird.

Ausnahmen

Der für einen set-Vorgang angegebene Wert war null.

Der Aufrufer verfügt nicht über die Berechtigung für den angeforderten Vorgang.

Beispiele

Im folgenden Codebeispiel wird die Select -Eigenschaft auf den leeren Proxy festgelegt.

#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();
        }
    }
}

Hinweise

Die Select -Eigenschaft legt den Proxy fest, den alle WebRequest Instanzen verwenden, wenn die Anforderung Proxys unterstützt und kein Proxy explizit mit der Proxy -Eigenschaft festgelegt wird. Proxys werden derzeit von FtpWebRequest und HttpWebRequestunterstützt.

Gilt für: