开发者

Return from redirect

开发者 https://www.devze.com 2023-01-07 14:28 出处:网络
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 redirec开发者_开发百科ted page?In the filter:

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 redirec开发者_开发百科ted page?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消