If Not HttpContext.Current.Request.Url.AbsoluteUri.Contains("https://") Then If ConfigurationManager.AppSettings("UseSecure").ToLower() = "true" Then Dim securePages As String = ConfigurationManager.AppSettings("SecurePages") Dim securePagesList As String() = securePages.Split(",") Dim IsSSLPage = False For Each page In securePagesList If strUrl.IndexOf(page) <> -1 Then If strUrl.IndexOf(".aspx") > 0 And HttpContext.Current.Request.ServerVariables("HTTPS") = "off" Then IsSSLPage = True Exit For End If End If Next Common.RedirectWithSSL(IsSSLPage) End If End If
Public Shared Sub RedirectWithSSL(ByVal isSSL As Boolean) If HttpContext.Current.Request.HttpMethod.ToLower() = "post" Then Return End If Dim httpurl As [String] = System.Web.HttpContext.Current.Request.Url.ToString() Dim checkUrl As String = httpurl.ToLower() If isSSL And httpurl.ToLower().StartsWith("http://") AndAlso Not httpurl.ToLower().StartsWith("https://") Then httpurl = httpurl.Replace("http", "https").ToString() System.Web.HttpContext.Current.Response.Redirect(httpurl) ElseIf Not isSSL And checkUrl.StartsWith("https://") Then httpurl = httpurl.Replace("https", "http").ToString() System.Web.HttpContext.Current.Response.Redirect(httpurl) End If End Sub
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)