System.Net.ICredentialPolicy

Defines the credential policy to be used for resource requests that are made using System.Net.WebRequest and its derived classes.

See Also: ICredentialPolicy Members

Syntax

public interface ICredentialPolicy

Remarks

The credential policy determines whether to send credentials when sending a System.Net.WebRequest for a network resource, such as the content of a Web page. If credentials are sent, servers that require client authentication can attempt to authenticate the client when the request is received instead of sending a response that indicates that the client's credentials are required. While this saves a round trip to the server, this performance gain must be balanced against the security risk inherent in sending credentials across the network. When the destination server does not require client authentication, it is best not to send credentials.

Note:

System.Net.ICredentialPolicy policies are invoked only if the System.Net.WebRequest or the System.Net.WebProxy that is associated with the request has credentials that are not null. Setting this policy has no effect on requests that do not specify credentials.

Use the AuthenticationManager.CredentialPolicy property to set an System.Net.ICredentialPolicy policy. The System.Net.IAuthenticationModule that handles authentication for the request will invoke the ICredentialPolicy.ShouldSendCredential(Uri, WebRequest, NetworkCredential, IAuthenticationModule) method before performing the authentication. If the method returns false, authentication is not performed.

An System.Net.ICredentialPolicy policy affects all instances of System.Net.WebRequest with non-null credentials in the current application domain. The policy cannot be overridden on individual requests.

Requirements

Namespace: System.Net
Assembly: System (in System.dll)
Assembly Versions: 2.0.0.0, 4.0.0.0
Since: .NET 2.0