HttpRequest.IsSecureConnection Property

Definition

取得值,這個執會指示 HTTP 連接是否使用安全通訊 (也就是,HTTPS)。Gets a value indicating whether the HTTP connection uses secure sockets (that is, HTTPS).

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

Property Value

Boolean

如果連接為 SSL 連接,則為 true;否則為 falsetrue if the connection is an SSL connection; otherwise, false.

Examples

下列程式碼範例會判斷 IsSecureConnection 屬性是否設定為 false。The following code example determines whether the IsSecureConnection property is set to false. 如果是,SuppressContent 屬性會設定為 true,以停止傳送回應。If it is, the SuppressContent property is set to true to stop the response from being sent.

// Check whether the request is sent
// over HTTPS. If not, do not send 
// content to the client.    
if (!Request.IsSecureConnection)
{
    Response.SuppressContent = true;
}
' Check whether the request is sent
' over HTTPS. If not, do not return
' content to the client.
If (Request.IsSecureConnection = False) Then      
    Response.SuppressContent = True
End If

Applies to