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

后端 未结 6 1062
攒了一身酷
攒了一身酷 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:23

    Try This.

    var ctrl= new MyController();
    ctrl.ControllerContext = ControllerContext;
    //call action
    return ctrl.Action();
    

提交回复
热议问题