CredentialCache.Remove 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
从缓存删除 NetworkCredential 实例。
重载
Remove(Uri, String) |
如果 NetworkCredential 实例与指定的统一资源标识符 (URI) 前缀和身份验证协议相关联,则将其从缓存中删除。 |
Remove(String, Int32, String) |
如果 NetworkCredential 实例与指定的主机、端口和身份验证协议相关联,则将其从缓存中删除。 |
Remove(Uri, String)
- Source:
- CredentialCache.cs
- Source:
- CredentialCache.cs
- Source:
- CredentialCache.cs
如果 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 前缀和身份验证协议与凭据关联的协议匹配,则此方法将从 CredentialCache 中删除NetworkCredential实例。 对同一 NetworkCredential 方法的多次调用Remove不起作用。
如果 authType
为 null
或 uriPrefix
为 null
,或者在缓存中找不到匹配的凭据,则此方法不执行任何工作。
适用于
Remove(String, Int32, String)
- Source:
- CredentialCache.cs
- Source:
- CredentialCache.cs
- Source:
- CredentialCache.cs
如果 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
为 null
或 uriPrefix
为 null
,或者在缓存中找不到匹配的凭据,则此方法不执行任何工作。