Service Fabric - Calling one controller from another (REST API)

Here's some code to show how it's done:

[Route("api/[controller]")]
[ApiController]
public class MySecondController : ControllerBase
{
   [HttpPut("{param}")]
   public ActionResult<string> Update([FromRoute]string param)
   {
      // do some important work...

      // call the First Controller
      var ctrl = new MyFirstController();
      ctrl.ControllerContext = ControllerContext;
      return ctrl.Get(parm);

Comments