HttpListenerRequest.IsSecureConnection 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取一个 Boolean 值,该值指示用来发送请求的 TCP 连接是否使用安全套接字层 (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 提供有关错误的信息的 。