Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

IWebProxy.GetProxy Method

Returns the URI of a proxy.

[Visual Basic]
Function GetProxy( _
   ByVal destination As Uri _
) As Uri
Uri GetProxy(
   Uri destination
Uri* GetProxy(
   Uri* destination
function GetProxy(
   destination : Uri
) : Uri;


A Uri specifying the requested Internet resource.

Return Value

A Uri containing the URI of the proxy used to contact destination.


The GetProxy method returns the URI of the proxy server that handles requests to the Internet resource specified in the destination parameter.


[Visual Basic, C#, C++] The following example uses the GetProxy method to return the URI that the WebRequest uses to access the Internet resource.

[Visual Basic] 

 Public Shared Sub Main()
     Dim webProxy_Interface As New WebProxy_Interface(New Uri("http://proxy.server.com"))
     webProxy_Interface.Credentials = New NetworkCredential("microsoft", ".Net")
     Console.WriteLine("The web proxy is : {0}", webProxy_Interface.GetProxy(New Uri("http://www.microsoft.com")))
     'Check if the webproxy can ne bypassed for the site "http://www.microsoft.com".
 console.writeline("For the Uri http://www.microsoft.com , the ")
     If webProxy_Interface.IsBypassed(New Uri("http://www.microsoft.com")) Then
         Console.WriteLine("webproxy is by passed")
         Console.WriteLine("webproxy is not bypassed")
     End If 
 End Sub 'Main

WebProxy_Interface webProxy_Interface = new WebProxy_Interface(new Uri("http://proxy.server.com"));

webProxy_Interface.Credentials = new NetworkCredential("microsoft", ".Net");

Console.WriteLine("The web proxy is : {0}", webProxy_Interface.GetProxy(new Uri("http://www.microsoft.com")));

// Check if the webproxy can ne bypassed for the site "http://www.microsoft.com".
if(webProxy_Interface.IsBypassed(new Uri("http://www.microsoft.com")))
    Console.WriteLine("Web Proxy is by passed");
    Console.WriteLine("Web Proxy is not by passed");

WebProxy_Interface* webProxy_Interface =
   new WebProxy_Interface(new Uri(S"http://proxy.server.com"));
webProxy_Interface->Credentials =
   new NetworkCredential(S"microsoft", S".Net");

Console::WriteLine(S"The web proxy is : {0}",
   webProxy_Interface->GetProxy(new Uri(S"http://www.microsoft.com")));

// Check if the webproxy can ne bypassed for the site S"http://www.microsoft.com".
if (webProxy_Interface->IsBypassed(new Uri(S"http://www.microsoft.com")))
   Console::WriteLine(S"Web Proxy is by passed");
   Console::WriteLine(S"Web Proxy is not by passed");

[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.


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

See Also

IWebProxy Interface | IWebProxy Members | System.Net Namespace

© 2015 Microsoft