本文整理匯總了C#中System.Net.AuthenticationManager.CustomTargetNameDictionary屬性的典型用法代碼示例。如果您正苦於以下問題:C# AuthenticationManager.CustomTargetNameDictionary屬性的具體用法?C# AuthenticationManager.CustomTargetNameDictionary怎麽用?C# AuthenticationManager.CustomTargetNameDictionary使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類System.Net.AuthenticationManager
的用法示例。
在下文中一共展示了AuthenticationManager.CustomTargetNameDictionary屬性的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: RequestResource
public static void RequestResource(Uri resource)
{
// Set policy to send credentials when using HTTPS and basic authentication.
// Create a new HttpWebRequest object for the specified resource.
WebRequest request=(WebRequest) WebRequest.Create(resource);
// Supply client credentials for basic authentication.
request.UseDefaultCredentials = true;
request.AuthenticationLevel = AuthenticationLevel.MutualAuthRequired;
HttpWebResponse response = (HttpWebResponse) request.GetResponse();
// Determine mutual authentication was used.
Console.WriteLine("Is mutually authenticated? {0}", response.IsMutuallyAuthenticated);
System.Collections.Specialized.StringDictionary spnDictionary = AuthenticationManager.CustomTargetNameDictionary;
foreach (System.Collections.DictionaryEntry e in spnDictionary)
{
Console.WriteLine("Key: {0} - {1}", e.Key as string, e.Value as string);
}
// Read and display the response.
System.IO.Stream streamResponse = response.GetResponseStream();
System.IO.StreamReader streamRead = new System.IO.StreamReader(streamResponse);
string responseString = streamRead.ReadToEnd();
Console.WriteLine(responseString);
// Close the stream objects.
streamResponse.Close();
streamRead.Close();
// Release the HttpWebResponse.
response.Close();
}
/*
The output from this example will differ based on the requested resource
and whether mutual authentication was successful. For the purpose of illustration,
a sample of the output is shown here:
Is mutually authenticated? True
Key: http://server1.someDomain.contoso.com - HTTP/server1.someDomain.contoso.com
<html>
...
</html>
*/