Freigeben über


IWebProxy.Credentials-Eigenschaft

Die für die Authentifizierung an den Proxyserver zu sendenden Anmeldeinformationen.

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

Syntax

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

value = instance.Credentials

instance.Credentials = value
ICredentials Credentials { get; set; }
property ICredentials^ Credentials {
    ICredentials^ get ();
    void set (ICredentials^ value);
}
/** @property */
ICredentials get_Credentials ()

/** @property */
void set_Credentials (ICredentials value)
function get Credentials () : ICredentials

function set Credentials (value : ICredentials)

Eigenschaftenwert

Eine ICredentials-Instanz, die die zum Authentifizieren einer Anforderung beim Proxyserver erforderlichen Anmeldeinformationen enthält.

Hinweise

Die Credentials-Eigenschaft ist eine ICredentials-Instanz, die die Anmeldeinformationen für die Authentifizierung enthält, die als Antwort auf den Statuscode HTTP 407 (Proxyautorisierung) an den Proxyserver gesendet werden sollen.

Beispiel

Im folgenden Beispiel wird die Credentials-Eigenschaft auf die Anmeldeinformationen festgelegt, die bei der Authentifizierung an den Proxyserver gesendet werden.

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 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;

    }
};
public ref 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;
   }

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

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

   // Return whether the web proxy should be bypassed for the specified destination (hostUri).
   virtual bool IsBypassed( Uri^ hostUri )
   {
      // Never bypass the proxy.
      return false;
   }
};
public class WebProxyInterface implements IWebProxy
{
    // The credentials to be used with the web proxy.
    private ICredentials iCredentials;
    // Uri of the associated proxy server.
    private Uri webProxyUri;

    public WebProxyInterface(Uri proxyUri) 
    {
        webProxyUri = proxyUri;
    } //WebProxyInterface 
   
    // Get and Set the Credentials property.
   
    /** @property 
     */
    public ICredentials get_Credentials()
    {
        return iCredentials ;
    } //get_Credentials

    /** @property 
     */
    public void set_Credentials (ICredentials value)
    {
        if (iCredentials != value) {
            iCredentials = value;
        }
    } //set_Credentials
   
    // Return the web proxy for the specified destination(destUri).
    public Uri GetProxy(Uri destUri) 
    {
        // Always use the same proxy.
        return webProxyUri ;
    } //GetProxy

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

Plattformen

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

.NET Compact Framework

Unterstützt in: 2.0, 1.0

Siehe auch

Referenz

IWebProxy-Schnittstelle
IWebProxy-Member
System.Net-Namespace