次の方法で共有


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

注釈

相互認証を要求するには、 または MutualAuthRequired 列挙値をWebRequest.AuthenticationLevel使用して プロパティをMutualAuthRequested設定します。 プロパティの既定値には、 WebRequest.AuthenticationLevelMutualAuthRequestedDelegation含まれています。

このプロパティを取得すると、 がスロー ObjectDisposedExceptionされる可能性があることに注意してください。

適用対象