WebNov 8, 2024 · You can call one controller function from another but the best way is to create a trait and use it both the controllers like: trait Common { public function method () {} } class FirstController extends Controller { use Common; } class SecondController extends Controller { use Common; } Share Improve this answer Follow WebOct 7, 2024 · I would encapsulate the logic you want to call in separate class, then simply instantiate the class and call it. Controllers should be a light weight implementation …
Call SignalR Core Hub method from Controller
WebDec 30, 2024 · 1. You shouldn't have to call another project's API controllers from another API controller. You should instead refactor the logic into a common class library and use that from both. Controllers are meant to be called from … WebOct 7, 2024 · there are some common methods (action) in /member, and some different methods, i try to create a controller for deal with common methods 1. Create a plain class ( not a controller!) for this and pass arguments- if you have common methods that does not involves html code 2. books on how to be a better listener
How to call a controller action from another project code example
WebExample: asp.net call controller from another controller public class HomeController : Controller { private Areas.Api.Controllers.FoobarController _foobarController; WebJan 31, 2014 · Others have pointed out that you should not often (ever?) call one view controller endpoint from another, but in the case that you need/want to, you need to be sure the target has been initialized properly. This is done using ControllerBuilder. So instead of: var result = new itemController (); return result.Get (query); // this will blow up! WebJun 28, 2016 · In my opinion calling a Controller from another Controller is not a good practice. Try using return redirect:/function1 to call the function1 inside Controller2. If it is a common function / service try writing a helper which would do … books on how to be a godly wife