GlobalProxySelection.GetEmptyWebProxy Methode
Definition
Wichtig
Einige Informationen beziehen sich auf Vorabversionen, die vor dem Release ggf. grundlegend überarbeitet werden. Microsoft übernimmt hinsichtlich der hier bereitgestellten Informationen keine Gewährleistungen, seien sie ausdrücklich oder konkludent.
Gibt eine leere Proxyinstanz zurück.
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
Gibt zurück
Ein IWebProxy, der keine Informationen enthält.
Beispiele
Im folgenden Codebeispiel wird eine WebRequest instance erstellt, die keinen Proxy verwendet.
#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 GetEmptyWebProxy Methode gibt einen leeren IWebProxy instance zurück, um anzugeben, dass kein Proxy für den Zugriff auf eine Internetressource verwendet wird.
Anstatt die GetEmptyWebProxy
-Methode aufzurufen, können Sie Membern wie der WebClient.Proxy -Eigenschaft zuweisennull
, die den Proxy angibt, der im Namen des WebClient -Objekts mit Remoteservern kommuniziert.
Gilt für:
Feedback
https://aka.ms/ContentUserFeedback.
Bald verfügbar: Im Laufe des Jahres 2024 werden wir GitHub-Issues stufenweise als Feedbackmechanismus für Inhalte abbauen und durch ein neues Feedbacksystem ersetzen. Weitere Informationen finden Sie unterFeedback senden und anzeigen für