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

后端 未结 6 1061
攒了一身酷
攒了一身酷 2021-02-07 10:45

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

6条回答
  •  灰色年华
    2021-02-07 11:19

    As controllers are just classes: Yes, we can do it. We can do it by some of the following ways:

    1. By directly redirecting- return RedirectToAction("MethodName", "ControllerName");

    2. By creating object - ControllerName objController=new ControllerName(); objController.methodName(parameters)

提交回复
热议问题