开发者

Passing useful message from a controller to another redirected controller

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 t开发者_如何学编程his?


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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜