I want to pass a message from the X view driver to the Y visa
ViewBag.Message = "Mensaje";
return RedirectToAction("Index", "Y");
when trying this does not work, not with the View (), how can I do it?
I want to pass a message from the X view driver to the Y visa
ViewBag.Message = "Mensaje";
return RedirectToAction("Index", "Y");
when trying this does not work, not with the View (), how can I do it?
If you make a RedirectToAction
what you will get is that the action of the other controller is executed, losing the values that you have put in ViewBag
.
If you want to render the view with the information generated in this action you should return it with the View
method indicating the full route of the view:
return View("~/Views/Y/Index.cshtml");