logo
Welcome to our new AbleCommerce forums. As a guest, you may view the information here. To post to this forum, you must have a registered account with us, either as a new user evaluating AbleCommerce or an existing user of the application. For all questions related to the older version of Gold and earlier, please go to AbleCommerce Gold forum. Please use your AbleCommerce username and password to Login. New Registrations are disabled.

Notification

Icon
Error

Options
Go to last post Go to first unread
Joe Payne2  
#1 Posted : Thursday, October 8, 2020 12:59:32 PM(UTC)
Joe Payne2

Rank: Advanced Member

Groups: HelpDesk, Developers
Joined: 11/9/2018(UTC)
Posts: 564

Thanks: 122 times
Was thanked: 26 time(s) in 25 post(s)
For the life of me I can't get a redirect to work from inside a simple widget I built. I just want to redirect back to the store home page with the desired affiliate id query string.

Every time, the store home page renders inside the existing page instead of redirecting the entire browser.

How do you do it?

Code:

        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult NoAffiliate(NoAffiliateModel model)
        {
            if (ModelState.IsValid)
            {
                // check the affiliate ID
                Affiliate affiliate = _affRepo.Load(AlwaysConvert.ToInt(model.AffiliateId));
                if (affiliate != null)
                {
                    string homeUrl = NavigationHelper.GetHomeUrl();
                    homeUrl += "/?afid=" + affiliate.Id;
                    return JavaScriptRedirect(Url.Content(homeUrl));
                }

                model.IsFailure = true;
                model.IsMessagePanelVisible = true;
                return PartialView("_NoAffiliate", model);
            }

            return PartialView("_NoAffiliate", model);
        }

Wanna join the discussion?! Login to your AbleCommerce Forums forum account. New Registrations are disabled.

Joe Payne2  
#2 Posted : Thursday, October 8, 2020 1:58:32 PM(UTC)
Joe Payne2

Rank: Advanced Member

Groups: HelpDesk, Developers
Joined: 11/9/2018(UTC)
Posts: 564

Thanks: 122 times
Was thanked: 26 time(s) in 25 post(s)
Finally think I found the solution. I so hate MVC, Javascript and diesel pickup trucks

Code:

                    string redirectUrl = "/";
                    return JavaScript(string.Format("window.location = '{0}'", redirectUrl));
Users browsing this topic
Guest (2)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.