Pass Data with ViewBag.Message

0

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?

    
asked by Sebastian Rico 26.02.2018 в 21:53
source

1 answer

2

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");
    
answered by 26.02.2018 в 22:05