Export (0) Print
Expand All

IWebProxy.Credentials Property

The credentials to submit to the proxy server for authentication.

[Visual Basic]
Property Credentials As ICredentials
[C#]
ICredentials Credentials {get; set;}
[C++]
__property ICredentials* get_Credentials();
__property void set_Credentials(ICredentials*);
[JScript]
function get Credentials() : ICredentials;function set Credentials(ICredentials);

Property Value

An ICredentials that contains the credentials needed to authenticate a request to the proxy server.

Remarks

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

[Visual Basic] 
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




[C#] 
public class WebProxy_Interface : IWebProxy

{

    // The credentials to be used with the web proxy.
    private ICredentials iCredentials;

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

    public WebProxy_Interface(Uri proxyUri) {

        webProxyUri = proxyUri;    

    }

    // Get and Set the Credentials property.
    public ICredentials Credentials {
        get {
            return iCredentials;
        }
        set {
            if(iCredentials != value)
                iCredentials = value;
        }
    }

    // Return the web proxy for the specified destination(destUri).
    public Uri GetProxy(Uri destUri) {

        // Always use the same proxy.
        return webProxyUri;

    }

    // Return whether the web proxy should be bypassed for the specified destination(hostUri).
    public bool IsBypassed(Uri hostUri) {

        // Never bypass the proxy.
        return false;

    }
};

[C++] 
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;
   }
};

Example

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

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

See Also

IWebProxy Interface | IWebProxy Members | System.Net Namespace

Show:
© 2014 Microsoft