2013-03-07 70 views
0

我有一個使用https的網頁。如果用戶更改了url例如:https://www.abc.com/page1.aspxhttp://www.abc.com/page1.aspx從http重定向到服務器端的https

我可以通過代碼,即Request.IsSecureConnection知道連接是否安全。我的問題是,如果用戶輸入http url。那麼如何通過VB中的服務器端代碼將其重定向到https。

+0

的可能重複[在asp.net迫使HTTPS的整個網站的最佳方式?(HTTP ://stackoverflow.com/questions/47089/best-way-in-asp-net-to-force-https-for-an-entire-site) – mellamokb 2013-03-07 16:02:30

回答

0

可以ReplaceHTTP通過HTTPS ...嘗試像下面這將幫助你..

If (Request.IsSecureConnection = False) Then 
     Dim Url As String 
     Url = Request.Url.ToString().Replace("http:", "https:") 
     Response.Redirect(Url) 
    End If