Export (0) Print
Expand All

AuthenticationManager.CredentialPolicy Property

Gets or sets the credential policy to be used for resource requests made using the HttpWebRequest class.

Namespace:  System.Net
Assembly:  System (in System.dll)

public static ICredentialPolicy CredentialPolicy { get; set; }

Property Value

Type: System.Net.ICredentialPolicy
An object that implements the ICredentialPolicy interface that determines whether credentials are sent with requests. The default value is null.

The credential policy determines whether to send credentials when sending a request 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 indicating that the client's credentials are required. While this saves a round trip to the server, this 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 to not send credentials.

The credential policy will be called only for requests that specify credentials or use a WebProxy object that specifies credentials.

The following code example demonstrates setting the credential policy.

 public static void UseIntranetCredentialPolicy()
{
    IntranetZoneCredentialPolicy  policy = new IntranetZoneCredentialPolicy();
    AuthenticationManager.CredentialPolicy = policy;
}

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft