WebResponse.IsMutuallyAuthenticated 속성

정의

상호 인증이 발생했는지 여부를 나타내는 Boolean 값을 가져옵니다.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

속성 값

클라이언트와 서버가 모두 인증되었으면 true이고, 그렇지 않으면 false입니다.true if both client and server were authenticated; otherwise, false.

예제

다음 코드 예제에서는이 속성의 값을 확인 합니다.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();
}

설명

상호 인증을 요청 하려면 설정 합니다 WebRequest.AuthenticationLevel 사용 하 여 속성을 MutualAuthRequested 또는 MutualAuthRequired 열거형 값입니다.To request mutual authentication, set the WebRequest.AuthenticationLevel property using the MutualAuthRequested or MutualAuthRequired enumeration value. 기본값은 WebRequest.AuthenticationLevel 속성을 포함 DelegationMutualAuthRequested합니다.The default value for the WebRequest.AuthenticationLevel property contains Delegation and MutualAuthRequested.

이 속성을 가져오면 수 throw ObjectDisposedException합니다.Note that getting this property can throw ObjectDisposedException.

적용 대상