HttpRequest.IsSecureConnection 屬性

定義

取得值,這個執會指示 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

屬性值

Boolean

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

範例

下列程式碼範例 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

適用於