0

passing some parameters in Html.ActionLink with QueryString Is Possible . but when using RedirectToAction how pass parameters . it just accept route value , i want to add ReturnValue Parameter to destination action that after action executed return to that like Login Mechanism , but how pass with RedirectToAction?

Moslem7026
  • 3,290
  • 6
  • 40
  • 51

2 Answers2

0

it is possible to add axtension Method to that like this

public static class RedirectToRouteExtensions
    {
        public static RedirectToRouteResult WithQuery(this RedirectToRouteResult redirectResult, string name, string val)
        {
            redirectResult.RouteValues.Add(name, val);
            return redirectResult;
        }
        public static RedirectToRouteResult And(this RedirectToRouteResult redirectResult, string name, string val)
        {
            return redirectResult.WithQuery(name, val);
        }
}

and use this :

return RedirectToAction("Index", "Profile", new { area = "Customer").WithQuery("name", "Value");

using route Values and QueryString Do Same , So What is Different Between Them?

Moslem7026
  • 3,290
  • 6
  • 40
  • 51
0

Any parameters that the destination action method requires can just be passed in the route values, e.g.

return RedirectToAction("Action", "Controller", new { returnValue = "returnValue" });
phil
  • 879
  • 1
  • 10
  • 20