CredentialCache.Remove Metodo

Definizione

Elimina un'istanza NetworkCredential dalla cache.

Overload

Nome Descrizione
Remove(Uri, String)

Elimina un'istanza NetworkCredential dalla cache se è associata al prefisso e al protocollo di autenticazione uniform resource identifier (URI) specificati.

Remove(String, Int32, String)

Elimina un'istanza NetworkCredential dalla cache se è associata all'host, alla porta e al protocollo di autenticazione specificati.

Remove(Uri, String)

Elimina un'istanza NetworkCredential dalla cache se è associata al prefisso e al protocollo di autenticazione uniform resource identifier (URI) specificati.

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)

Parametri

uriPrefix
Uri

Oggetto Uri che specifica il prefisso URI delle risorse per cui vengono usate le credenziali.

authType
String

Schema di autenticazione usato dall'host denominato in uriPrefix.

Esempio

Nell'esempio di codice seguente viene usato questo metodo per eliminare un'istanza NetworkCredential dalla 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()

Commenti

Questo metodo rimuove un'istanza NetworkCredentialCredentialCache da se il prefisso URI e il protocollo di autenticazione specificati corrispondono a quelli associati alle credenziali. Più chiamate al Remove metodo per lo stesso NetworkCredential non hanno alcun effetto.

Se authType è o è nullnull o uriPrefix non viene trovata alcuna credenziale corrispondente nella cache, questo metodo non esegue alcuna operazione.

Si applica a

Remove(String, Int32, String)

Elimina un'istanza NetworkCredential dalla cache se è associata all'host, alla porta e al protocollo di autenticazione specificati.

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)

Parametri

host
String

Oggetto String che identifica il computer host.

port
Int32

Oggetto Int32 che specifica la porta a cui connettersi in host.

authenticationType
String

Oggetto String che identifica lo schema di autenticazione utilizzato per la connessione a host.

Commenti

Questo metodo rimuove un'istanza NetworkCredential da se l'host CredentialCache , la porta e il protocollo di autenticazione specificati corrispondono a quelli associati alle credenziali. Più chiamate al Remove metodo per lo stesso NetworkCredential non hanno alcun effetto.

Se authenticationType è o è nullnull o uriPrefix non viene trovata alcuna credenziale corrispondente nella cache, questo metodo non esegue alcuna operazione.

Si applica a