Redirect with Transition

15 views
Skip to first unread message

Rick

unread,
Aug 23, 2011, 5:43:38 PM8/23/11
to magellan-friends
Is it possible to do a Redirect and have it honor a transition from
the original navigation?

BTW. I've restructed by app to not require it, so at this point it's
more of question for future refrence.

I had a page with a button that would navigate to a controller action
using the NavigateWithTransitionAction. That action would perform
it's operation but then needed to redirect to another controller.
That transition was not performed.

Thinking maybe the request lost the transition value during the
redirect I tried adding the transition to the request like below, but
that didn't work either.

private ActionResult RedirectWithTransition(string controller, string
action, string transition)
{
var request = new RouteValueDictionary();
request["controller"] = controller;
request["action"] = action;
request["Transition"] = transition;

return Redirect(request);
}

Thanks,
Rick...

Rick

unread,
Aug 23, 2011, 6:28:20 PM8/23/11
to magellan-friends
ok...so where is that 'undo-stupid-question' button.

Right after I sent my question, it dawned on me that I should also
check the transition string since that was something else that was
different from my other uses...sheesh. I had changed my "Forward" to
"Backward"...but it needed to be "Back".

so nevermind and I hope no one spent any time looking into this.

Paul Stovell

unread,
Aug 23, 2011, 7:39:28 PM8/23/11
to Rick, magellan-friends
Hi Rick,

So did the method setting the Transition value work as expected?

Paul

Sent from my Windows Phone From: Rick
Sent: Tuesday, 23 August 2011 11:28 PM
To: magellan-friends
Subject: Re: Redirect with Transition

Rick

unread,
Aug 24, 2011, 7:38:08 AM8/24/11
to magellan-friends
Yes, it did.

I changed the XAML to use NavigateControllerAction, then the
Controller action did a return RedirectWithTransition()

Rick

unread,
Aug 24, 2011, 5:45:27 PM8/24/11
to magellan-friends
I tested one more scenario.

The Page includes a button with a NavigateWithTransitionAction
trigger.
The Controller action returns a normal RedirectResult.

This does not perform the Transition as specified by the page.

Which makes sense, since the Redirect is performing a new navigation
and doesn't copy the route values dictionary initial navigation.

Further testing yielded this routine:

private ActionResult MyRedirect(string controller, string action)
{

var request = new RouteValueDictionary();
request["controller"] = controller;
request["action"] = action;

string routeTransition = this.Request.RouteValues["Transition"] as
string;
if (!string.IsNullOrWhiteSpace(routeTransition))
request["Transition"] = routeTransition;

return Redirect(request);
}

This does perform the transition as specified by the initial request.

Rick...
Reply all
Reply to author
Forward
0 new messages