IWebProxy.Credentials プロパティ
認証用にプロキシ サーバーに送信する資格情報。
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);
プロパティ値
プロキシ サーバーへの要求を認証するために必要な資格情報を格納している ICredentials 。
解説
Credentials プロパティは、HTTP 407 (プロキシ認証) ステータス コードに応答して、プロキシ サーバーに送信する認証資格情報を格納している ICredentials インスタンスです。
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;
}
};
使用例
認証のためプロキシ サーバーに送信される資格情報を Credentials プロパティを使用して設定する例を次に示します。
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, .NET Compact Framework - Windows CE .NET, Common Language Infrastructure (CLI) Standard