从操作重定向到在MVC不同的控制器另一个动作 [英] Redirect from action to another action in different controller in MVC

查看:100
本文介绍了从操作重定向到在MVC不同的控制器另一个动作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要做的是从A控制器的操作重定向到B控制器的操作它给了我这个错误,它找不到目标控制器这个动作

What I want to do is to redirect from an action in "A" controller to an action in "B" controller it gives me this error that it can not find this action in the target controller

我使用 RedirectToAction 方法的任何帮助。

I am using RedirectToAction Method any help

推荐答案

您的控制器内的操作添加此

within your A controller add this in your action

RedirectToAction(new {controller="B", action="index", id=11,variable="abc"});

这就是如果你要送也是一些参数,但不要忘了有配置的路由,可以映射变量参数为好。我认为这是目前解决

that's if you want to send some parameters also ,but do not forget to have a route configured which can map the "variable" parameter as well. I think this is solved in now

这篇关于从操作重定向到在MVC不同的控制器另一个动作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆