共用方式為


HttpListenerRequest.IsSecureConnection 屬性

定義

取得 Boolean 值,指出用來傳送要求的 TCP 連線是否使用 Secure Sockets Layer (SSL) 通訊協定。

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

屬性值

如果 TCP 連線使用 SSL,則為 true,否則為 false

範例

下列程式代碼範例示範如何使用 IsSecureConnection 屬性。

public static void ShowRequestProperties2 (HttpListenerRequest request)
{
    Console.WriteLine("KeepAlive: {0}", request.KeepAlive);
    Console.WriteLine("Local end point: {0}", request.LocalEndPoint.ToString());
    Console.WriteLine("Remote end point: {0}", request.RemoteEndPoint.ToString());
    Console.WriteLine("Is local? {0}", request.IsLocal);
    Console.WriteLine("HTTP method: {0}", request.HttpMethod);
    Console.WriteLine("Protocol version: {0}", request.ProtocolVersion);
    Console.WriteLine("Is authenticated: {0}", request.IsAuthenticated);
    Console.WriteLine("Is secure: {0}", request.IsSecureConnection);
}
Public Shared Sub ShowRequestProperties2(ByVal request As HttpListenerRequest)
    Console.WriteLine("KeepAlive: {0}", request.KeepAlive)
    Console.WriteLine("Local end point: {0}", request.LocalEndPoint.ToString())
    Console.WriteLine("Remote end point: {0}", request.RemoteEndPoint.ToString())
    Console.WriteLine("Is local? {0}", request.IsLocal)
    Console.WriteLine("HTTP method: {0}", request.HttpMethod)
    Console.WriteLine("Protocol version: {0}", request.ProtocolVersion)
    Console.WriteLine("Is authenticated: {0}", request.IsAuthenticated)
    Console.WriteLine("Is secure: {0}", request.IsSecureConnection)
End Sub

備註

若要要求安全連線,用戶端要求會使用 UriSchemeHttps 而不是 UriSchemeHttp。 如果無法使用 SSL 建立連線,用戶端會收到 提供 WebException 錯誤相關信息的 。

適用於

另請參閱