0

I' working on a MVC C# project and I have this action thata receives a string type id

public ActionResult Administracion(string id) 
        {

and I need to send the id value from another action (inside the same controller), this is what I have for the time being in the action from where I want to send the id

return RedirectToAction("Administracion");

my question is how to send the id using the RedirectToAction? thanks

Pablo Tobar
  • 614
  • 2
  • 13
  • 37

1 Answers1

0

You can pass route values as an optional argument to RedirectToAction.

return RedirectToAction("Administracion", new { id = "123" });

Edit: as others have noted this is a duplicate of another question. RedirectToAction with parameter

BenM
  • 121
  • 7
  • thanks, and in case I want to pass a property(the value of the property: clase.noDoc) I should use: return RedirectToAction("Administracion", new { id = clase.noDoc.ToString() }); ?? – Pablo Tobar Jul 19 '17 at 21:21
  • Yes. The anonymous type object simply defines the names and values of the URL query string. – Kim Jul 20 '17 at 08:38
  • If this answered your question, please mark it as the answer. Thanks! – BenM Jul 20 '17 at 14:37