System.Net.ICredentialPolicy.ShouldSendCredential Method

Returns a bool that indicates whether the client's credentials are sent with a resource request made using an instance of the System.Net.WebRequest class.

Syntax

public bool ShouldSendCredential (Uri challengeUri, WebRequest request, NetworkCredential credential, IAuthenticationModule authenticationModule)

Parameters

challengeUri
The Uri that will receive the request. For more information, see the Remarks section.
request
The System.Net.WebRequest that represents the resource being requested.
credential
The System.Net.NetworkCredential that will be sent with the request if this method returns true.
authenticationModule
The System.Net.IAuthenticationModule that will conduct the authentication, if authentication is required.

Returns

true if the credentials are sent with the request; otherwise, false.

Remarks

After an System.Net.ICredentialPolicy policy has been specified by setting the AuthenticationManager.CredentialPolicy property, the System.Net.IAuthenticationModule that handles authentication for a System.Net.WebRequest invokes the ICredentialPolicy.ShouldSendCredential(Uri, WebRequest, NetworkCredential, IAuthenticationModule) method before performing the authentication. If this method returns false, authentication is not performed.

When the original request has been redirected or proxy authentication is required, the resource identified by challengeUri can be different from the requested resource that is specified in WebRequest.RequestUri. In the case of redirection, challengeUri contains the actual destination Uri. If proxy authentication is required, challengeUri contains the address of the proxy server that requires client authentication.

Requirements

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