Condividi tramite


WebResponse.IsMutuallyAuthenticated Proprietà

Definizione

Ottiene un valore Boolean che indica se è stata effettuata l'autenticazione reciproca.

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

Valore della proprietà

true se il client che il server sono stati autenticati entrambi; in caso contrario false.

Esempio

Nell'esempio di codice seguente viene controllato il valore di questa proprietà.


// 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();
}

Commenti

Per richiedere l'autenticazione reciproca, impostare la WebRequest.AuthenticationLevel proprietà usando il MutualAuthRequested valore di enumerazione o MutualAuthRequired . Il valore predefinito per la WebRequest.AuthenticationLevel proprietà contiene Delegation e MutualAuthRequested.

Si noti che il recupero di questa proprietà può generare ObjectDisposedException.

Si applica a