0

So, I'm creating a basic time table application, and I want to pass the user name to another controller like that:

//POST

[HttpPost]
[ValidateAntiForgeryToken]
public IActionResult Index(Login obj)
{
    return RedirectToAction(actionName:
        "Index", controllerName:
        "EmploiDuTemps", obj.Name);
}

and I try to receive it on the other controller like this :

public IActionResult Index(string obj)
{
   
    return View(obj);
}

so I can use it the view, but it doesn't work, can someone help me?

  • https://stackoverflow.com/questions/15385442/passing-data-between-different-controller-action-methods here – KOMODO Aug 08 '22 at 10:02
  • @KOMODO thanks for your help but unfortunatly the answer is depreciated with mvc 5 but it gave me a different pov on my problem, thanks – Charles Marguerite Aug 08 '22 at 11:28
  • return RedirectToAction(actionName: "Index", controllerName: "EmploiDuTemps", new{obj=obj.Name}); ... try this – KOMODO Aug 08 '22 at 12:15
  • Try to pass route values like this `return RedirectToAction("Index", "EmploiDuTemps", new { obj = obj.Name });` – Abdul Haseeb Aug 08 '22 at 19:36

0 Answers0