I'm working on an MVC4 project that has site controllers and API controllers. How do I send a request to an API controller from one of the site controllers?
For example, I might have an APiController that looks like this:
public class FooController : ApiController {
[HttpGet]
public int Add(int a, int b) {
return a + b;
}
}
How would I send a request to /FooController/Add?a=1;b=2 from this Controller?
public class BarController : Controller {
[HttpGet]
public int AddOneAndTwo() {
//What goes here?
}
}
EDIT: What I really wanted to do was call methods from my ApiController class from my site Controller, and I assumed I had to conjure some MVC4 magic to make it work. As per the comments between Felix and me, I can just create an instance of my ApiController in my site Controller and go from there. But if you still need to access ApiController methods via HTTP, then boy howdy, is Felix's answer to my original question for you.