GlobalProxySelection.Select Proprietà
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Ottiene o imposta il proxy HTTP globale.
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
Valore della proprietà
IWebProxy utilizzato da ogni chiamata a GetResponse().
Eccezioni
Il valore specificato per un'operazione di impostazione era null.
Il chiamante non ha l'autorizzazione per l'operazione richiesta.
Esempio
Nell'esempio di codice seguente la proprietà viene impostata sul Select proxy vuoto.
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();
}
}
}
Commenti
La Select proprietà imposta il proxy usato da tutte le WebRequest istanze se la richiesta supporta i proxy e nessun proxy viene impostato in modo esplicito usando la Proxy proprietà . I proxy sono attualmente supportati da FtpWebRequest e HttpWebRequest.