问题
So I have two projects in my solution. Both are WebApi. I have controllers in both and I can call them from the client side - javascript. The problem is that I need to call a method in the controller of the second project from method in the controller of the first project. I also think I should state that the method I need to call is Post so I need to send it parameters as well. Is this possible at all? I heard about "RedirectToAction" method but I think this won't work in webapi.
回答1:
You should not need to POST to the second controller.
Create some shared code in your project and have both controllers use this. If you have the variables needed for a POST in the first controller, you can simply pass these to the shared method.
来源:https://stackoverflow.com/questions/24485765/call-webapi-controller-from-another-controller