Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET MVC Call method on different controller

Can anybody tell me how to call a method on a different controller from within an action method? I don't want to redirect. I want to call a method on a different controller that returns a string and use the response within my action method.

like image 391
user135498 Avatar asked Aug 18 '09 21:08

user135498


People also ask

Can we call method from one controller to another controller?

Yes, you can call a method of another controller. The controller is also a simple class.


1 Answers

Sounds in my ears like you should refactor your application, and extract the functionality that generates the string out to a new seperate class (or reuse an existing class, if you have one that fits) and let both controllers use that class.

like image 75
Pete Avatar answered Sep 24 '22 16:09

Pete