HttpDigestClientCredential.ClientCredential 属性

定义

获取或设置将用于基于摘要的身份验证的网络凭据。

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

属性值

NetworkCredential

将用于基于摘要的身份验证的 NetworkCredential

示例

下面的代码示例演示如何以不同的主体对客户端进行身份验证。

这就是如何更改此属性返回的 NetworkCredential 类的实例的属性。

private void Snippet2()
{
    using (CalculatorClient client = new CalculatorClient())
    {
        client.ClientCredentials.HttpDigest.ClientCredential.UserName = "test";
        client.ClientCredentials.HttpDigest.ClientCredential.Password = "password";
    }
}

此处演示如何创建 NetworkCredential 类的新实例以及将其分配给此属性。

private void Snippet3()
{
    using (CalculatorClient client = new CalculatorClient())
    {
        client.ClientCredentials.HttpDigest.ClientCredential = new NetworkCredential("test user", "password");
    }
}

注解

如果没有指定,则使用默认的线程凭据。

适用于