Can we call the Method of a controller from another controller in asp.net MVC?
Try this. I'm assuming you want to return that action's result. var ctrl= new MyController(); ctrl. ControllerContext = ControllerContext; //call action return ctrl.
You could also simply redirect straight to the method like so:
public class ThisController
{
public ActionResult Index()
{
return RedirectToAction("OtherMethod", "OtherController");
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With