从控制器传递有用的信息给另一个重定向器 [英] Passing useful message from a controller to another redirected controller
本文介绍了从控制器传递有用的信息给另一个重定向器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想打一个RedirectToAction用户点击一个按钮后。我重定向之前,我将信息存储到一个变量。最后,经过我都重定向到行动,我想展示一些有用的信息。我想这样的:
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?
推荐答案
您可以使用的TempData code>。
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.
下面是一些有用的链接
这篇关于从控制器传递有用的信息给另一个重定向器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文