WebResponse.IsMutuallyAuthenticated WebResponse.IsMutuallyAuthenticated WebResponse.IsMutuallyAuthenticated WebResponse.IsMutuallyAuthenticated Property

Definizione

Ottiene o imposta un valore Boolean che indica se è stata effettuata l'autenticazione reciproca.Gets a Boolean value that indicates whether mutual authentication occurred.

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.true if both client and server were authenticated; otherwise, false.

Esempi

Nell'esempio di codice seguente viene controllato il valore di questa proprietà.The following code example checks the value of this property.

// The following example uses the System, System.Net, 
// and System.IO namespaces.
static void RequestMutualAuth( Uri^ resource )
{
   // Create a new HttpWebRequest object for the specified resource.
   WebRequest^ request = dynamic_cast<WebRequest^>(WebRequest::Create( resource ));

   // Request mutual authentication.
   request->AuthenticationLevel = AuthenticationLevel::MutualAuthRequested;

   // Supply client credentials.
   request->Credentials = CredentialCache::DefaultCredentials;
   HttpWebResponse^ response = dynamic_cast<HttpWebResponse^>(request->GetResponse());

   // Determine whether mutual authentication was used.
   Console::WriteLine( L"Is mutually authenticated? {0}", response->IsMutuallyAuthenticated );

   // Read and display the response.
   Stream^ streamResponse = response->GetResponseStream();
   StreamReader^ streamRead = gcnew StreamReader( streamResponse );
   String^ responseString = streamRead->ReadToEnd();
   Console::WriteLine( responseString );

   // Close the stream objects.
   streamResponse->Close();
   streamRead->Close();

   // Release the HttpWebResponse.
   response->Close();
}

// 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 WebRequest.AuthenticationLevel , impostare la MutualAuthRequested proprietà MutualAuthRequired usando il valore di enumerazione o.To request mutual authentication, set the WebRequest.AuthenticationLevel property using the MutualAuthRequested or MutualAuthRequired enumeration value. Il valore predefinito per la WebRequest.AuthenticationLevel proprietà contiene Delegation e MutualAuthRequested.The default value for the WebRequest.AuthenticationLevel property contains Delegation and MutualAuthRequested.

Si noti che il recupero di questa ObjectDisposedExceptionproprietà può generare.Note that getting this property can throw ObjectDisposedException.

Si applica a