views:

5

answers:

1

How can i redirect user in filter to another action and remember action which he wanted to do before redirect and repeat it after he do any action on that redirected page?

A: 

In the filter:

public override void OnActionExecuting(ActionExecutingContext filterContext)
{
    var dictionary = new RouteValueDictionary();
    dictionary["action"] = "newaction";
    dictionary["controller"] = "home";
    dictionary["returnUrl"] = filterContext.RequestContext.HttpContext.Request.Url.AbsoluteUri;
    filterContext.Result = new RedirectToRouteResult(dictionary);
}

And then use the returnUrl parameter in the new action.

Darin Dimitrov