Returns the System.Net.NetworkCredential instance associated with the specified Uniform Resource Identifier (URI) and authentication type.
- uriPrefix
- A Uri that specifies the URI prefix of the resources that the credential grants access to.
- authType
- The authentication scheme used by the resource named in uriPrefix.
A System.Net.NetworkCredential or, if there is no matching credential in the cache, null.
Type Reason ArgumentNullException The uriPrefix or authType parameter is null.
The CredentialCache.GetCredential(Uri, string) method searches the System.Net.CredentialCache and returns the System.Net.NetworkCredential instance for the specified URI and authorization type. If the System.Net.CredentialCache contains no matching System.Net.NetworkCredential instance, null is returned.
CredentialCache.GetCredential(Uri, string) uses the longest matching URI prefix in the cache to determine which set of credentials to return for an authorization type. The following table shows examples.
http://www.contoso.com/portal/news.htm |
Requests for the specific Web page news.htm. |
http://www.contoso.com/portal/ |
Requests for all content in the portal path, except the page news.htm. |
http://www.contoso.com/ |
Requests for all resources at www.contoso.com, except those in the portal path. |