TeamMentor.CoreLib.HandleUrlRequest.redirectedToSSL C# (CSharp) Method

redirectedToSSL() public method

public redirectedToSSL ( ) : bool
return bool
        public bool redirectedToSSL()
        {
            try
            {
                if (SSL_Redirection_Disabled)               // so that we only do this check once per server
                    return false;
                if (TMConfig.Current.TMSecurity.SSL_RedirectHttpToHttps &&
                    context.Request.IsLocal.isFalse() &&
                    context.Request.IsSecureConnection.isFalse())
                {
                    if (request.Url != null)
                    {
                        if (sslPageIsAvailable())           // addresses issue that happened when an SSL redirection was set for a server without SSL configured
                        {
                            var originalRequest = request.Url.str();
                            var redirectUrl     = originalRequest.Replace("http://", "https://");
                            "[redirectedToSSL] Redirecting original request '{0}' to {1}".info(originalRequest,redirectUrl);
                            context.Response.Redirect(redirectUrl);
                            return true;
                        }
                        "[redirectedToSSL] since sslPageIsAvailable was failed, setting SSL_Redirection_Disabled to true".debug();
                        SSL_Redirection_Disabled = true;                // prevents multiple attemps to check for redirections (was causing lots of error messages on live servers)
                    }
                }
            }
            catch (Exception ex)
            {
                ex.log("[in redirectedToSLL]");
            }
            return false;
        }