CredentialCache.Remove Méthode

Définition

Supprime une NetworkCredential instance du cache.

Surcharges

Nom Description
Remove(Uri, String)

Supprime une NetworkCredential instance du cache s’il est associé au préfixe et au protocole d’authentification uniform Resource Identifier (URI) spécifiés.

Remove(String, Int32, String)

Supprime une NetworkCredential instance du cache si elle est associée à l’hôte, au port et au protocole d’authentification spécifiés.

Remove(Uri, String)

Supprime une NetworkCredential instance du cache s’il est associé au préfixe et au protocole d’authentification uniform Resource Identifier (URI) spécifiés.

public:
 void Remove(Uri ^ uriPrefix, System::String ^ authType);
public void Remove(Uri uriPrefix, string authType);
member this.Remove : Uri * string -> unit
Public Sub Remove (uriPrefix As Uri, authType As String)

Paramètres

uriPrefix
Uri

Qui Uri spécifie le préfixe d’URI des ressources pour lesquelles les informations d’identification sont utilisées.

authType
String

Schéma d’authentification utilisé par l’hôte nommé dans uriPrefix.

Exemples

L’exemple de code suivant utilise cette méthode pour supprimer une NetworkCredential instance du cache.

// Create a webrequest with the specified url.
WebRequest myWebRequest = WebRequest.Create(url);
myWebRequest.Credentials = myCredentialCache;
Console.WriteLine("\nLinked CredentialCache to your request.");
// Send the request and wait for response.
WebResponse myWebResponse = myWebRequest.GetResponse();

// Process response here.

Console.Write("Response received successfully.");
// Call 'Remove' method to dispose credentials for current Uri as not required further.
myCredentialCache.Remove(myWebRequest.RequestUri,"Basic");
Console.WriteLine("\nYour credentials have now been removed from the program's CredentialCache");
myWebResponse.Close();
' Create a webrequest with the specified url .
Dim myWebRequest As WebRequest = WebRequest.Create(url)
myWebRequest.Credentials = myCredentialCache
Console.WriteLine(ControlChars.Cr + "Linked CredentialCache to your request.")
' Send the request and wait for response.
Dim myWebResponse As WebResponse = myWebRequest.GetResponse()

'Process the response here

Console.Write("Response received successfully.")
'Call 'Remove' method to dispose credentials for current Uri as they would not be; 
'required in any of the future requests.
myCredentialCache.Remove(myWebRequest.RequestUri, "Basic")
Console.WriteLine(ControlChars.Cr + "Your credentials have now been removed from the program's CredentialCache")
myWebResponse.Close()

Remarques

Cette méthode supprime une NetworkCredential instance si CredentialCache le préfixe d’URI et le protocole d’authentification spécifiés correspondent à ceux associés aux informations d’identification. Plusieurs appels à la Remove méthode pour le même NetworkCredential n’ont aucun effet.

Si authType elle est null ou uriPrefix est null, ou qu’aucune information d’identification correspondante n’est trouvée dans le cache, cette méthode ne fait rien.

S’applique à

Remove(String, Int32, String)

Supprime une NetworkCredential instance du cache si elle est associée à l’hôte, au port et au protocole d’authentification spécifiés.

public:
 void Remove(System::String ^ host, int port, System::String ^ authenticationType);
public void Remove(string host, int port, string authenticationType);
member this.Remove : string * int * string -> unit
Public Sub Remove (host As String, port As Integer, authenticationType As String)

Paramètres

host
String

Qui String identifie l’ordinateur hôte.

port
Int32

Qui Int32 spécifie le port auquel se connecter .host

authenticationType
String

Qui String identifie le schéma d’authentification utilisé lors de la connexion à host.

Remarques

Cette méthode supprime une NetworkCredential instance de l’hôte CredentialCache , du port et du protocole d’authentification spécifiés qui correspondent à celles associées aux informations d’identification. Plusieurs appels à la Remove méthode pour le même NetworkCredential n’ont aucun effet.

Si authenticationType elle est null ou uriPrefix est null, ou qu’aucune information d’identification correspondante n’est trouvée dans le cache, cette méthode ne fait rien.

S’applique à