Answer the question
In order to leave comments, you need to log in
How to pass data between asp.net mvc controllers?
There are 2 methods, generally located in different controllers:
public ActionResult FirstMethod()
{
...
ViewBag.Message = "My message";
return RedirectToAction("SecondMethod");
}
public ActionResult SecondMethod()
{
...
return View();
}
Answer the question
In order to leave comments, you need to log in
Solved the problem by using the TempData property.
public ActionResult FirstMethod()
{
...
TempData["Message"] = "My message";
return RedirectToAction("SecondMethod");
}
public ActionResult SecondMethod()
{
...
ViewBag.Message = TempData["Message"];
return View();
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question