Set Viewbag before Redirect

When you use redirection, you shall not use ViewBag, but TempData

public ActionResult Action1 () {
 TempData["shortMessage"] = "MyMessage";
 return RedirectToAction("Action2");
}

public ActionResult Action2 () {
 //now I can populate my ViewBag (if I want to) with the TempData["shortMessage"] content
  ViewBag.Message = TempData["shortMessage"].ToString();
  return View();
}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)