Export (0) Print
Expand All

GlobalProxySelection::GetEmptyWebProxy Method

Returns an empty proxy instance.

Namespace:  System.Net
Assembly:  System (in System.dll)

public:
static IWebProxy^ GetEmptyWebProxy()

Return Value

Type: System.Net::IWebProxy
An IWebProxy that contains no information.

The GetEmptyWebProxy method returns a blank IWebProxy instance to indicate that no proxy is used to access an Internet resource.

The following code example creates a WebRequest instance that does not use a 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;
}

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Show:
© 2015 Microsoft