0

Is possible to convert a string into routeValues?

Per example:

return RedirectToAction("Index", "Home", new { id = 1});

to

return RedirectToAction("Index", "Home", "id = 1");

I am needing it because I want to save the routeValues in database.

I already read this: convert string into (object) routeValues C# but the guy doesn't know if that is the more supported way.

Community
  • 1
  • 1
Dan
  • 1,518
  • 5
  • 20
  • 48
  • can you not save the full url in the database? `var url = Url.Action("Index", "Home", new { id = 1});` then you just use `return Redirect(url);` – JamieD77 Jul 07 '15 at 21:26

1 Answers1

1

RedirectToAction also takes a RouteValueDictionary which might be usable in your case. You'd have to construct it a little differently.

var routeVals = new RouteValueDictionary(){"id", "1"};
return RedirectToAction("Index", "Home", routeVals);
JamieD77
  • 13,796
  • 1
  • 17
  • 27