Поделиться через


WebResponse.IsMutuallyAuthenticated Свойство

Определение

Возвращает значение Boolean, указывающее, была ли выполнена взаимная проверка подлинности.

public:
 virtual property bool IsMutuallyAuthenticated { bool get(); };
public virtual bool IsMutuallyAuthenticated { get; }
member this.IsMutuallyAuthenticated : bool
Public Overridable ReadOnly Property IsMutuallyAuthenticated As Boolean

Значение свойства

Значение true, если и клиент, и сервер прошли проверку подлинности; в противном случае — false.

Примеры

В следующем примере кода проверяется значение этого свойства.


// The following example uses the System, System.Net,
// and System.IO namespaces.

public static void RequestMutualAuth(Uri resource)
{
    // Create a new HttpWebRequest object for the specified resource.
    WebRequest request=(WebRequest) WebRequest.Create(resource);
    // Request mutual authentication.
   request.AuthenticationLevel = AuthenticationLevel.MutualAuthRequested;
    // Supply client credentials.
    request.Credentials = CredentialCache.DefaultCredentials;
    HttpWebResponse response = (HttpWebResponse) request.GetResponse();
    // Determine whether mutual authentication was used.
    Console.WriteLine("Is mutually authenticated? {0}", response.IsMutuallyAuthenticated);
    // Read and display the response.
    Stream streamResponse = response.GetResponseStream();
    StreamReader streamRead = new StreamReader(streamResponse);
    string responseString = streamRead.ReadToEnd();
   Console.WriteLine(responseString);
    // Close the stream objects.
    streamResponse.Close();
    streamRead.Close();
    // Release the HttpWebResponse.
    response.Close();
}

Комментарии

Чтобы запросить взаимную WebRequest.AuthenticationLevel проверку подлинности, задайте свойство с MutualAuthRequested помощью значения перечисления или MutualAuthRequired . Значение по умолчанию для WebRequest.AuthenticationLevel свойства содержит Delegation и MutualAuthRequested.

Обратите внимание, что получение этого свойства может вызвать исключение ObjectDisposedException.

Применяется к