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
?
Asked
Active
Viewed 655 times
0

Moslem7026
- 3,290
- 6
- 40
- 51
-
2possible duplicate with [this](http://stackoverflow.com/questions/11209191/how-do-i-include-a-model-with-a-redirecttoaction) – Daniele Sep 08 '13 at 07:29
-
What Is Different Between `RoutValue` And `Query String` ? visit the Answer – Moslem7026 Sep 08 '13 at 07:41
2 Answers
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