public void ManageSSLConnection()
 {
     ApplicationController objAppController = new ApplicationController();
     if (!objAppController.CheckRequestExtension(Request))
     {
         if (Session[SessionKeys.Ssl] == null)
         {
             Session[SessionKeys.Ssl] = "True";
             //check logic redirect to or not
             //btn click login and logout prob
             PageController objController = new PageController();
             List<SecurePageInfo> sp = objController.GetSecurePage(currentportalID, GetCurrentCulture());
             string pagename = GetPageSEOName(PagePath);
             if (pagename != "Page-Not-Found")
             {
                 if (Session[SessionKeys.pagename] != null)
                 {
                     prevpage = Session[SessionKeys.pagename].ToString();
                 }
                 if (prevpage != pagename)
                 {
                     Session[SessionKeys.pagename] = pagename;
                     for (int i = 0; i < sp.Count; i++)
                     {
                         if (pagename.ToLower() == sp[i].SecurePageName.ToString().ToLower())
                         {
                             if (bool.Parse(sp[i].IsSecure.ToString()))
                             {
                                 if (!HttpContext.Current.Request.IsSecureConnection)
                                 {
                                     if (!HttpContext.Current.Request.Url.IsLoopback) //Don't check when in development mode (i.e. localhost)
                                     {
                                         Session[SessionKeys.prevurl] = "https";
                                         Response.Redirect(Request.Url.ToString().Replace("http://", "https://"));
                                     }
                                 }
                             }
                             else
                             {
                                 Session[SessionKeys.prevurl] = "http";
                                 Response.Redirect(Request.Url.ToString().Replace("https://", "http://"));
                             }
                         }
                     }
                 }
                 else if (Session[SessionKeys.prevurl] != null)
                 {
                     if (Session[SessionKeys.prevurl].ToString() != Request.Url.ToString().Split(':')[0].ToString())
                     {
                         for (int i = 0; i < sp.Count; i++)
                         {
                             if (pagename.ToLower() == sp[i].SecurePageName.ToString().ToLower())
                             {
                                 if (bool.Parse(sp[i].IsSecure.ToString()))
                                 {
                                     if (!HttpContext.Current.Request.IsSecureConnection)
                                     {
                                         if (!HttpContext.Current.Request.Url.IsLoopback) //Don't check when in development mode (i.e. localhost)
                                         {
                                             Response.Redirect(Request.Url.ToString().Replace("http://", "https://"));
                                         }
                                     }
                                 }
                                 else
                                 {
                                     Response.Redirect(Request.Url.ToString().Replace("https://", "http://"));
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }