how to add querystring values with RedirectToAction method?
Solution 1:
Any values that are passed that aren't part of the route will be used as querystring parameters:
return this.RedirectToAction
("myActionName", new { value1 = "queryStringValue1" });
Would return:
/controller/myActionName?value1=queryStringValue1
Assuming there's no route parameter named "value1".
Solution 2:
For people like me who were looking to add the CURRENT querystring values to the RedirectToAction, this is the solution:
var routeValuesDictionary = new RouteValueDictionary();
Request.QueryString.AllKeys.ForEach(key => routeValuesDictionary.Add(key, Request.QueryString[key]));
routeValuesDictionary.Add("AnotherFixedParm", "true");
RedirectToAction("ActionName", "Controller", routeValuesDictionary);
The solution as you can see is to use the RouteValueDictionary object