redirect onepagecheckout

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
7 years ago
Hi there,

in an actionfilter (on OPCSAVESHIPPING) I'm trying to redirect to the cart page and display a warning notification

if I do this: it works however doesn't seem to allow the "notification" to popup (presumably because the REDIRECT interrupts the setting of this value?? solutions?)...

filterContext.Controller.AddNotification(NotifyType.Success, "NOTE: you should re-check your totals", true);
filterContext.Result = new RedirectToRouteResult("/cart", null);


if I do this: it doesn't work at all...
filterContext.Controller.AddNotification(NotifyType.Success, "NOTE: you should re-check your totals", true);
filterContext.Result = new RedirectResult("/cart");


Maybe with onepagecheckouts AJAX might be getting in the way of something.
Any thoughts/ideas welcome.

How are you supposed to redirect and display a message in this kind of situation?
7 years ago
---- UPDATE ----
this seems to have the correct impact:

if (filterContext.HttpContext.Request.IsAjaxRequest())
   filterContext.Result = new JavaScriptResult() {Script = "window.location = \"/cart\""};
else
   filterContext.Result = new RedirectResult("~/cart");


HOWEVER, setting "TempData" on the controller doesn't appear to work in teh way I think it should.
filterContext.Controller.TempData["Something"]="Wazzzaaaup?";

this line works fine, however when you get to the view "TempData" is actually got 0 items.

Is this because the CONTROLLER (in filterContext.Controller) is "CheckoutController" and the "cart" lives in "ShoppingCartController" or is it because the OPC is AJAX that the "tempdata" is being read and dissapearing before the actual CART page is loaded...?

Please help!
7 years ago
Okay so I think its fair to say that unless I'm missing something the hints and doco I've read is somewhat unclear/misleading/I didnt' read carefully enough?

some suggests that "TempData" (which is what NOP uses to store the "Notifications") is "persisted between requests",

however other info suggests that "TempData" is to be used to "persist between controller actions".

Implying that CHANGING the controller is a "no"... and I've been smashing my head against this for no reason...

**IF** this is the case then has anyone got good ideas how to implement something like this?

"action filter" (doesn't have to be this but this is how weve approached it.
onexecutING -> check soemthing in customer info and store it
onexecutED -> if the thing was modified in a particular way redirect the user and notify them that this option is not allowed in this case.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.