IWebProxy.Credentials プロパティ

定義

認証用にプロキシ サーバーに送信する資格情報。

public:
 property System::Net::ICredentials ^ Credentials { System::Net::ICredentials ^ get(); void set(System::Net::ICredentials ^ value); };
public System.Net.ICredentials Credentials { get; set; }
public System.Net.ICredentials? Credentials { get; set; }
member this.Credentials : System.Net.ICredentials with get, set
Public Property Credentials As ICredentials

プロパティ値

プロキシ サーバーへの要求を認証するために必要な資格情報を格納している ICredentials インスタンス。

次の例では、 プロパティを Credentials 使用して、認証のためにプロキシ サーバーに送信される資格情報を設定します。

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

    '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

注釈

プロパティは CredentialsICredentials HTTP 407 (プロキシ承認) 状態コードに応答してプロキシ サーバーに送信する承認資格情報を含むインスタンスです。

適用対象