protected void Application_BeginRequest(object sender, EventArgs e)
        {
            //Ignore if a file is requsted.
            Regex regex = new Regex(@".(txt|gif|pdf|doc|docx|jpg|pdf|js|png|mp4|aspx|asp|html|htm|css|scss|less|eot|svg|ttf|woff|otf|xml)$");

            if (regex.IsMatch(Request.Url.AbsoluteUri))
            {
                return;
            }
            if (Request.Url.AbsoluteUri.ToLower().Contains("/rem_a2"))
            {
                return;
            }

            //Continue with redirection
            SitePreference sitePref = CSFactory.GetCacheSitePref();

            //if (!sitePref.AttributeValuesLoaded)
            sitePref.LoadAttributeValues();
            if (sitePref.ContainsAttribute("redirecturls"))
            {
                string redirectUrl = RedirectToUrls(sitePref.AttributeValues["redirecturls"].Value);
                if (redirectUrl.Length > 0)
                {
                    Response.Redirect(redirectUrl);
                }
            }
        }
        public static void CallCartCompute(Cart cart)
        {
            try
            {
                /*
                 * // Use for logging
                 * if (CSFactory.GetCacheSitePref().GetAttributeValue("EnableFreeShipMainSku", false))
                 * {
                 * }
                 * else
                 * {
                 *  CSCore.CSLogger.Instance.LogException("EnableFreeShipMainSku is not set", new Exception("custom error"));
                 *
                 *  CSCore.CSLogger.Instance.LogException("CSFactory.GetCacheSitePref().VersionItems: " + (CSFactory.GetCacheSitePref().VersionItems == null).ToString(), new Exception("custom error"));
                 *
                 *  if (CSFactory.GetCacheSitePref().VersionItems == null)
                 *  {
                 *      CSCore.CSLogger.Instance.LogException("CSFactory.GetCacheSitePref().VersionItems.Count: " + (CSFactory.GetCacheSitePref().VersionItems.Count).ToString(), new Exception("custom error"));
                 *  }
                 *
                 *  CSCore.CSLogger.Instance.LogException("CSFactory.GetCacheSitePref().AttributeValues: " + (CSFactory.GetCacheSitePref().AttributeValues == null).ToString(), new Exception("custom error"));
                 *
                 *  CSCore.CSLogger.Instance.LogException("CSFactory.GetCacheSitePref().AttributeValuesLoaded: " + (CSFactory.GetCacheSitePref().AttributeValuesLoaded).ToString(), new Exception("custom error"));
                 *
                 *  if (CSFactory.GetCacheSitePref().AttributeValues != null)
                 *  {
                 *      CSCore.CSLogger.Instance.LogException("CSFactory.GetCacheSitePref().AttributeValues.Count: " + (CSFactory.GetCacheSitePref().AttributeValues.Count).ToString(), new Exception("custom error"));
                 *  }
                 * }
                 */
                SitePreference sitePreference = CSFactory.GetCacheSitePref();



                sitePreference.LoadAttributeValues();
                if (sitePreference.AttributeValuesLoaded && sitePreference.ContainsAttribute("AutoDiscountCode"))
                {
                    if (sitePreference.GetAttributeValue("AutoDiscountCode") != null)



                    {
                        cart.DiscountCode = sitePreference.GetAttributeValue("AutoDiscountCode");
                        cart.Compute();
                    }
                }
            }



            catch (Exception ex)
            {
                CSCore.CSLogger.Instance.LogException("Error logging tests", ex);
            }
        }
 public void LoadScripts(Page page)
 {
     //Adding scripts to header
     if (CartContext != null)
     {
         SitePreference sitePref = CSFactory.GetCacheSitePref();
         if (!sitePref.AttributeValuesLoaded)
         {
             sitePref.LoadAttributeValues();
         }
         if (sitePref.AttributeValues != null)
         {
             if (sitePref.ContainsAttribute("scripts") != null)
             {
                 Literal li = new Literal();
                 li.Text = sitePref.AttributeValues["scripts"].Value;
                 if (page.Header != null)
                 {
                     page.Header.Controls.Add(li);
                 }
             }
         }
     }
 }