本文整理汇总了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>
*/