コード例 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //try
            //{
            var redirectAfterHandle = new BasketRequestHandler().HandleBasketRequest(Request.Form, HttpContext.Current.Request.Url);

            if (redirectAfterHandle == null || !redirectAfterHandle.Any())
            {
                return;
            }

            string redirectUrl;
            var    url = redirectAfterHandle.Last().Url;

            if (url == HttpContext.Current.Request.Url)
            {
                redirectUrl = HttpContext.Current.Request.RawUrl;
            }
            else
            {
                redirectUrl = url.AbsoluteUri;
            }

            if ((Request.Form.AllKeys.Any() && (Request.Form.AllKeys.Any(x => x == "disableReload") || Request.Form.AllKeys.Any(x => x == "disableRedirect"))))
            {
                return;
            }

            var validateOrderReffererKey = Request.Form.AllKeys.FirstOrDefault(x => x.ToLower() == "backtoreferreronerror");

            if (validateOrderReffererKey != null && redirectAfterHandle.Any(x => x.Validated == false))
            {
                var validateOrderRefferer = Request.Form[validateOrderReffererKey];

                if ((validateOrderRefferer.ToLower() == "true" || validateOrderRefferer.ToLower() == "backtoreferreronerror" || validateOrderRefferer.ToLower() == "on" || validateOrderRefferer == "1") && HttpContext.Current.Request.UrlReferrer != null)
                {
                    redirectUrl = redirectUrl.Replace(HttpContext.Current.Request.Url.AbsolutePath, HttpContext.Current.Request.UrlReferrer.AbsolutePath);
                }
            }

            Response.Redirect(redirectUrl, false);

            //}
            //catch (ThreadAbortException)
            //{
            //}
            ////catch (Exception ex)
            //{
            //	//throw;
            //	//Log.Instance.LogError(ex, "Unhandled exception during execution of uWebshop basket handler");
            //}
        }
コード例 #2
0
        public ActionResult Handle()
        {
            var refferer = HttpContext.Request.UrlReferrer;

            var redirectAfterHandle = new BasketRequestHandler().HandleBasketRequest(Request.Form, refferer);

            if (Request.UrlReferrer == null)
            {
                return(CurrentUmbracoPage());
            }

            foreach (var result in redirectAfterHandle)
            {
                Log.Instance.LogDebug("Handle Result: " + result.Action + "result.Success: " + result.Success + "result.Validated: " + result.Validated + "result.PostConfirmUrl: " + result.PostConfirmUrl);
            }

            var redirectUrl = HttpContext.Request.RawUrl;

            var postConfirmUrlHandler = redirectAfterHandle.LastOrDefault(x => x.PostConfirmUrl != null);

            if (postConfirmUrlHandler != null)
            {
                var postConfirmUrl = postConfirmUrlHandler.PostConfirmUrl;

                if (postConfirmUrl != null)
                {
                    redirectUrl = postConfirmUrl.AbsoluteUri;
                }
            }

            var validateOrderReffererKey = Request.Form.AllKeys.FirstOrDefault(x => x.ToLower() == "backtoreferreronerror");

            if (validateOrderReffererKey != null && redirectAfterHandle.Any(x => x.Validated == false))
            {
                var validateOrderRefferer = Request.Form[validateOrderReffererKey];

                if ((validateOrderRefferer.ToLower() == "true" || validateOrderRefferer.ToLower() == "backtoreferreronerror" || validateOrderRefferer.ToLower() == "on" || validateOrderRefferer == "1") && HttpContext.Request.UrlReferrer != null)
                {
                    redirectUrl = HttpContext.Request.UrlReferrer.AbsolutePath;
                }
            }

            Log.Instance.LogDebug("Handle Result redirectUrl: " + redirectUrl);

            return(Redirect(redirectUrl));
        }