Export (0) Print
Expand All

GlobalProxySelection.Select Property

Gets or sets the global HTTP proxy.

[Visual Basic]
Public Shared Property Select As IWebProxy
[C#]
public static IWebProxy Select {get; set;}
[C++]
public: __property static IWebProxy* get_Select();
public: __property static void set_Select(IWebProxy*);
[JScript]
public static function get Select() : IWebProxy;
public static function set Select(IWebProxy);

Property Value

An IWebProxy that every call to HttpWebRequest.GetResponse uses.

Exceptions

Exception Type Condition
SecurityException The caller does not have permission for the requested operation.

Remarks

The Select method sets the proxy that all HttpWebRequest instances use.

Example

[Visual Basic, C#, C++] The following example uses the Select property to get the global HTTP proxy.

[Visual Basic] 
' Attach the WebProxy instance to the GlobalProxySelection class.
GlobalProxySelection.Select = myWebProxy

' Create an HttpWebRequest object. The request object will be automatically assigned 
' to the same proxy object that is assigned to GlobalProxySelection.

Dim myHttpWebRequest As HttpWebRequest = CType(WebRequest.Create(remoteUrl), HttpWebRequest)
Dim myHttpWebResponse As HttpWebResponse = CType(myHttpWebRequest.GetResponse(), HttpWebResponse)
Console.WriteLine((ControlChars.Cr + "Request to remote Uri  " + remoteUrl + " sent ........"))
If myHttpWebResponse.StatusCode = HttpStatusCode.OK Then
    Console.WriteLine(ControlChars.Cr + "Response obtained successfully")
End If 

[C#] 
// Attach the WebProxy instance to the GlobalProxySelection class.
GlobalProxySelection.Select = myWebProxy;
// Create an HttpWebRequest object. The request object will be automatically assigned 
//to the same proxy object that is assigned to GlobalProxySelection.
HttpWebRequest myHttpWebRequest   = (HttpWebRequest)WebRequest.Create(remoteUrl);
HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
Console.WriteLine("\nRequest to remote Uri  " + remoteUrl + " sent ........");
if (myHttpWebResponse.StatusCode == HttpStatusCode.OK)
  Console.WriteLine("\nResponse obtained successfully");


[C++] 
// Attach the WebProxy instance to the GlobalProxySelection class.
GlobalProxySelection::Select = myWebProxy;
// Create an HttpWebRequest Object*. The request Object* will be automatically assigned
//to the same proxy Object* that is assigned to GlobalProxySelection.
HttpWebRequest* myHttpWebRequest   
   = dynamic_cast<HttpWebRequest*>(WebRequest::Create(remoteUrl));
HttpWebResponse* myHttpWebResponse 
   = dynamic_cast<HttpWebResponse*>(myHttpWebRequest->GetResponse());
Console::WriteLine(S"\nRequest to remote Uri {0} sent ........", remoteUrl);
if (myHttpWebResponse->StatusCode == HttpStatusCode::OK)
   Console::WriteLine(S"\nResponse obtained successfully");

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard

.NET Framework Security: 

See Also

GlobalProxySelection Class | GlobalProxySelection Members | System.Net Namespace

Show:
© 2014 Microsoft