Export (0) Print
Expand All

IWebProxy.Credentials Property

The credentials to submit to the proxy server for authentication.

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

'Declaration
Property Credentials As ICredentials
'Usage
Dim instance As IWebProxy 
Dim value As ICredentials 

value = instance.Credentials

instance.Credentials = value

Property Value

Type: System.Net.ICredentials
An ICredentials instance that contains the credentials that are needed to authenticate a request to the proxy server.

The Credentials property is an ICredentials instance that contains the authorization credentials to send to the proxy server in response to an HTTP 407 (proxy authorization) status code.

The following example uses the Credentials property to set the credentials that will be submitted to the proxy server for authentication.

Public Class WebProxy_Interface
    Implements IWebProxy


    'The credentials to be used with the web proxy. 
    Private iCredentials As ICredentials

    'Uri of the associated proxy server. 
    Private webProxyUri As Uri


    Sub New(proxyUri As Uri)

        webProxyUri = proxyUri
    End Sub 'New  


    'Get and Set the Credentials property. 

    Public Property Credentials() As ICredentials Implements IWebProxy.Credentials
        Get 
            Return iCredentials
        End Get 
        Set 
            If iCredentials Is value Then
                iCredentials = value
            End If 
        End Set 
    End Property 

    'Returns the web proxy for the specified destination(destUri). 
    Public Function GetProxy(destUri As Uri) As Uri Implements IWebProxy.GetProxy

        'Always use the same proxy. 
        Return webProxyUri
    End Function 'GetProxy


    'Returns whether the web proxy should be bypassed for the specified destination(hostUri). 
    Public Function IsBypassed(hostUri As Uri) As Boolean Implements IWebProxy.IsBypassed
       'Never bypass the proxy. 
        Return False 
    End Function 'IsBypassed 
End Class 'WebProxy_Interface
public __gc class WebProxy_Interface : public IWebProxy {
private:
   // The credentials to be used with the web proxy.
   ICredentials*  iCredentials;

   // Uri of the associated proxy server.
   Uri*  webProxyUri;

public:
   WebProxy_Interface(Uri* proxyUri) {
      webProxyUri = proxyUri;
   }

   // Get and Set the Credentials property.
   __property ICredentials* get_Credentials() {
      return iCredentials;
   }
   __property void set_Credentials(ICredentials* value) {
      if (iCredentials != value)
         iCredentials = value;
   }

   // Return the web proxy for the specified destination(destUri).
   Uri* GetProxy(Uri* destUri) {
      // Always use the same proxy.
      return webProxyUri;
   }

   // Return whether the web proxy should be bypassed for the specified destination(hostUri).
   bool IsBypassed(Uri* hostUri) {
      // Never bypass the proxy.
      return false;
   }
};

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

Community Additions

ADD
Show:
© 2014 Microsoft