asp.net-mvc .NET MVC - 从另一个控制器操作调用控制器操作
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/409049/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
.NET MVC - Call a controller Action from another controller action
提问by iasksillyquestions
I have a controller action which I would like to call another controller action.
我有一个控制器动作,我想调用另一个控制器动作。
Is this a valid thing to do. Is it possible?
这是一个有效的做法。是否可以?
采纳答案by yfeldblum
Controller.RedirectToAction
Controller.RedirectToAction
回答by tvanfosson
As @Justice says you can use RedirectToAction. Also, you can use TempData to pass model (and other) data between controller actions.
正如@Justice 所说,您可以使用 RedirectToAction。此外,您可以使用 TempData 在控制器操作之间传递模型(和其他)数据。

