System.Net.WebProxy.Credentials Property

Gets or sets the credentials to submit to the proxy server for authentication.

Syntax

public ICredentials Credentials { get; set; }

Value

A System.Net.ICredentials object containing the credentials to submit to the proxy server for authentication.

Remarks

The WebProxy.Credentials property contains the authentication credentials to send to the proxy server in response to an HTTP 407 (proxy authorization) status code. In most client scenarios, you should use the CredentialCache.DefaultCredentials, which are the credentials of the currently logged on user. To do this, set the WebProxy.UseDefaultCredentials property to true instead of setting this property.

Note:

If you set the WebProxy.Credentials property to credentials other than the CredentialCache.DefaultCredentials, setting the WebProxy.UseDefaultCredentials property to true causes a InvalidOperationException. To prevent this, you must set the WebProxy.Credentials property to null before setting the WebProxy.UseDefaultCredentials property to true. Likewise, you cannot set this property to any value when WebProxy.UseDefaultCredentials is true.

Requirements

Namespace: System.Net
Assembly: System (in System.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0