CredentialCache.Remove 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
將 NetworkCredential 執行個體從快取中刪除。
多載
Remove(Uri, String) |
從快取刪除 NetworkCredential 執行個體,如果它與所指定之統一資源識別元 (URI) 和驗證通訊協定關聯。 |
Remove(String, Int32, String) |
從快取刪除 NetworkCredential 執行個體,如果它與所指定之主機、連接埠和驗證通訊協定關聯。 |
Remove(Uri, String)
從快取刪除 NetworkCredential 執行個體,如果它與所指定之統一資源識別元 (URI) 和驗證通訊協定關聯。
public:
void Remove(Uri ^ uriPrefix, System::String ^ authType);
public void Remove (Uri uriPrefix, string authType);
public void Remove (Uri? uriPrefix, string? authType);
member this.Remove : Uri * string -> unit
Public Sub Remove (uriPrefix As Uri, authType As String)
參數
- authType
- String
由在 uriPrefix
中命名的主機所使用的驗證配置。
範例
下列程式代碼範例會使用這個方法從快取中刪除 NetworkCredential 實例。
// 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.
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()
備註
如果指定的 URI 前置詞和驗證通訊協定符合與認證相關聯的實例,這個方法就會 NetworkCredential 從 CredentialCache 中移除 實例。 相同 NetworkCredential 方法的Remove多個呼叫沒有任何作用。
如果 authType
為 或 uriPrefix
為 null
null
,或快取中找不到相符的認證,則此方法不會執行任何動作。
適用於
Remove(String, Int32, String)
從快取刪除 NetworkCredential 執行個體,如果它與所指定之主機、連接埠和驗證通訊協定關聯。
public:
void Remove(System::String ^ host, int port, System::String ^ authenticationType);
public void Remove (string host, int port, 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)
參數
備註
如果指定的主機、埠和驗證通訊協定符合與認證相關聯的實例,這個方法就會從 CredentialCache 中移除 NetworkCredential 實例。 相同 NetworkCredential 方法的Remove多個呼叫沒有任何作用。
如果 authType
為 或 uriPrefix
為 null
null
,或快取中找不到相符的認證,則此方法不會執行任何動作。