I’m looking for a way to use RedirectToAction while passing along the current request’s GET parameters.
So upon going to:
http://mydomain.com/MyController/MyRedirectAction?somevalue=1234
I would then want to redirect and persist somevalue with the a redirect without having to explicitly build a route dictionary and explicitly setting somevalue
public ActionResult MyRedirectAction()
{
if (SomeCondition)
RedirectToAction("MyAction", "Home");
}
The redirected action could then use somevalue if available:
public ActionResult MyAction()
{
string someValue = Request.QueryString["somevalue"];
}
Is there a clean way to do this?
A custom action result could do the job:
and then: