System.Net.AuthenticationManager.PreAuthenticate Method

Preauthenticates a request.

Syntax

public static Authorization PreAuthenticate (WebRequest request, ICredentials credentials)

Parameters

request
A System.Net.WebRequest to an Internet resource.
credentials
The System.Net.ICredentials associated with the request.

Returns

An instance of the System.Net.Authorization class if the request can be preauthenticated; otherwise, null. If credentials is null, this method returns null.

Exceptions

TypeReason
ArgumentNullException request is null.

Remarks

If the authentication module can preauthenticate the request, the AuthenticationManager.PreAuthenticate(WebRequest, ICredentials) method returns an Authentication instance and sends the authorization information to the server preemptively instead of waiting for the resource to issue a challenge. This behavior is outlined in section 3.3 of RFC 2617 (HTTP Authentication: Basic and Digest Access Authentication). Authentication modules that support preauthentication allow clients to improve server efficiency by avoiding extra round trips caused by authentication challenges.

Authorization modules that can preauthenticate requests set the IAuthenticationModule.CanPreAuthenticate property to true.

Requirements

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