Ejemplo n.º 1
0
        public virtual IActionResult SetStore(string store, string returnUrl = "")
        {
            var currentstoreid = _storeContext.CurrentStore.Id;

            if (currentstoreid != store)
            {
                _commonWebService.SetStore(store);
            }

            var prevStore = _storeService.GetStoreById(currentstoreid);
            var currStore = _storeService.GetStoreById(store);

            if (prevStore != null && currStore != null)
            {
                if (prevStore.Url != currStore.Url)
                {
                    return(Redirect(currStore.SslEnabled ? currStore.SecureUrl : currStore.Url));
                }
            }

            //home page
            if (String.IsNullOrEmpty(returnUrl))
            {
                returnUrl = Url.RouteUrl("HomePage");
            }

            //prevent open redirection attack
            if (!Url.IsLocalUrl(returnUrl))
            {
                returnUrl = Url.RouteUrl("HomePage");
            }

            return(Redirect(returnUrl));
        }