0

I have in a variable my query string

string queryString="tri=2&dd=3&order=4&.."

I need to redirect to action with my query string:

return RedirectToAction("Index", "call" new {queryString});

but i'm redirected to call/index/queryString=tri=2&dd=3&order=4&..

I need to be redirected to :

call/index/tri=2&dd=3&order=4&.. how can I do this please?

regards

user1428798
  • 1,534
  • 3
  • 24
  • 50
  • 2
    You can use `var queryString = new { tri = 2, dd = 3, order=4 }` to build an object, and then `return RedirectToAction("Index", "call", queryString);` –  Jul 18 '16 at 06:40
  • i get the query string from the database, is a long querystring with 50 params or more, so that's i don't prefer to build the object – user1428798 Jul 18 '16 at 06:42
  • Why in the world are you storing query string in a database? –  Jul 18 '16 at 06:43
  • to save the options of a favorite of user we are storing his querystring. it's an old system – user1428798 Jul 18 '16 at 06:46
  • 1
    Possible duplicate of [setting query string in redirecttoaction in asp.net mvc](http://stackoverflow.com/questions/12180387/setting-query-string-in-redirecttoaction-in-asp-net-mvc) – teo van kot Jul 18 '16 at 06:55
  • You can always build the url (e.g. `string url = Url.Action("Index", "call") + "?" + queryString;` and use `return Redirect(url);` –  Jul 18 '16 at 06:59

1 Answers1

3

You can try:

return Redirect("~/call/index/" + queryString);

Or

return RedirectToAction("index" + "/" + queryString, "call");
Phan Dinh
  • 245
  • 2
  • 11
  • Hi! Code only answers rarely provide much insight for the OP and future visitors, a good answer usually includes some detais in what OP was doing wrong and what your code does and how it solves the problem. – Epodax Jul 18 '16 at 08:36