ICredentialPolicy.ShouldSendCredential Method

Note: This method is new in the .NET Framework version 2.0.

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

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

Function ShouldSendCredential ( _
	challengeUri As Uri, _
	request As WebRequest, _
	credential As NetworkCredential, _
	authenticationModule As IAuthenticationModule _
) As Boolean
Dim instance As ICredentialPolicy
Dim challengeUri As Uri
Dim request As WebRequest
Dim credential As NetworkCredential
Dim authenticationModule As IAuthenticationModule
Dim returnValue As Boolean

returnValue = instance.ShouldSendCredential(challengeUri, request, credential, authenticationModule)
boolean ShouldSendCredential (
	Uri challengeUri, 
	WebRequest request, 
	NetworkCredential credential, 
	IAuthenticationModule authenticationModule
function ShouldSendCredential (
	challengeUri : Uri, 
	request : WebRequest, 
	credential : NetworkCredential, 
	authenticationModule : IAuthenticationModule
) : boolean



The Uri that will receive the request. For more information, see the Remarks section.


The WebRequest that represents the resource being requested.


The NetworkCredential that will be sent with the request if this method returns true.


The IAuthenticationModule that will conduct the authentication, if authentication is required.

Return Value

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

After an ICredentialPolicy policy has been specified by setting the AuthenticationManager.CredentialPolicy property, the IAuthenticationModule that handles authentication for a WebRequest invokes the ShouldSendCredential 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.

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

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

.NET Framework

Supported in: 2.0

Community Additions