我们可以从asp.net MVC中的另一个控制器调用一个控制器的方法吗? [英] Can we call the Method of a controller from another controller in asp.net MVC?

查看:317
本文介绍了我们可以从asp.net MVC中的另一个控制器调用一个控制器的方法吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们可以从asp.net MVC中的另一个控制器调用一个控制器的方法吗?

Can we call the Method of a controller from another controller in asp.net MVC?

推荐答案

您还可以直接将其直接重定向到该方法,如下所示:

You could also simply redirect straight to the method like so:

public class ThisController 
{
    public ActionResult Index() 
    {
       return RedirectToAction("OtherMethod", "OtherController");
    }
}

这篇关于我们可以从asp.net MVC中的另一个控制器调用一个控制器的方法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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