This documentation is archived and is not being maintained.

WebProxy.GetProxy Method

Returns the proxied URI for a request.

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

Public Function GetProxy ( _
	destination As Uri _
) As Uri
Dim instance As WebProxy 
Dim destination As Uri 
Dim returnValue As Uri 

returnValue = instance.GetProxy(destination)


Type: System.Uri

The Uri instance of the requested Internet resource.

Return Value

Type: System.Uri
The Uri instance of the Internet resource, if the resource is on the bypass list; otherwise, the Uri instance of the proxy.



The GetProxy method returns the URI that the WebRequest instance uses to access the Internet resource.

GetProxy compares destination with the contents of BypassList, using the IsBypassed method. If IsBypassed returns true, GetProxy returns destination and the WebRequest instance does not use the proxy server.

If destination is not in BypassList, the WebRequest instance uses the proxy server and the Address property is returned.

The following code example creates a WebProxy object and calls this method to get the proxy that is selected for a resource.

No code example is currently available or this language may not be supported.
// The following method creates a WebProxy object that uses Internet Explorer's  
// detected script if it is found in the registry; otherwise, it 
// tries to use Web proxy auto-discovery to set the proxy used for
// the request.

void CheckAutoGlobalProxyForRequest(Uri* resource)
    WebProxy* proxy = new WebProxy();

    // Display the proxy's properties.

    // See what proxy is used for the resource.
    Uri* resourceProxy = proxy->GetProxy(resource);

    // Test to see whether a proxy was selected.
    if (resourceProxy == resource)
        Console::WriteLine(S"No proxy for {0}", resource);
        Console::WriteLine(S"Proxy for {0} is {1}", resource->OriginalString,

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 3.5, 2.0, 1.0