次の方法で共有


CredentialCache.Remove メソッド

キャッシュから NetworkCredential インスタンスを削除します。

Public Sub Remove( _
   ByVal uriPrefix As Uri, _   ByVal authType As String _)
[C#]
public void Remove(UriuriPrefix,stringauthType);
[C++]
public: void Remove(Uri* uriPrefix,String* authType);
[JScript]
public function Remove(
   uriPrefix : Uri,authType : String);

パラメータ

  • uriPrefix
    資格情報が使用されるリソースの URI プリフィックスを指定する Uri
  • authType
    uriPrefix で指定されたホストが使用する認証方式。

解説

Remove メソッドは、指定した NetworkCredential インスタンスを CredentialCache から削除します。同じ NetworkCredential に対して Remove メソッドを何度も呼び出しても、効果はありません。

使用例

[Visual Basic, C#, C++] Remove メソッドを使用して、キャッシュから NetworkCredential インスタンスを削除する例を次に示します。

 
' 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()

[C#] 
// 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();        

[C++] 
// Create a webrequest with the specified url.
WebRequest* myWebRequest = WebRequest::Create(url);
myWebRequest->Credentials = myCredentialCache;
Console::WriteLine(S"\nLinked CredentialCache to your request.");
// Send the request and wait for response.
WebResponse* myWebResponse = myWebRequest->GetResponse();

// Process response here.

Console::Write(S"Response received successfully.");
// Call 'Remove' method to dispose credentials for current Uri as not required further.
myCredentialCache->Remove(myWebRequest->RequestUri, S"Basic");
Console::WriteLine(S"\nYour credentials have now been removed from the program's CredentialCache");
myWebResponse->Close();

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, Common Language Infrastructure (CLI) Standard

参照

CredentialCache クラス | CredentialCache メンバ | System.Net 名前空間