I want to make a RedirectToAction after the user clicks a button. Before I redirect, I store the information into a variable. At the end, after I have redirected to action, I want to show some useful information. I tried this:
ViewBag.message = "User with ID = " + id + " was changed status to verified.";
But the data will be flushed after redirection. Is there any other way to achieve this?
You can use TempData
.
TempData["message"] = "User with ID = " + id + " was changed status to verified.";
It is stored in session but after you access it, it will be removed.
Here are some useful links
Passing Data in an ASP.NET MVC Application
Difference Between ViewData and TempData?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With