GlobalProxySelection.GetEmptyWebProxy Metodo
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.
Restituisce un'istanza di proxy vuota.
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
Restituisce
IWebProxy che non contiene informazioni.
Esempio
Nell'esempio di codice seguente viene creata un'istanza WebRequest che non usa un proxy.
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
Il metodo restituisce un'istanza GetEmptyWebProxy vuota IWebProxy per indicare che non viene usato alcun proxy per accedere a una risorsa Internet.
Anziché chiamare il GetEmptyWebProxy metodo, è possibile assegnare null ai membri, ad esempio la WebClient.Proxy proprietà, che specifica il proxy che comunica con server remoti per conto dell'oggetto WebClient .