0

On startup, how do I execute an async function inside another class by redirecting a route?

The code below first runs the Home() function inside the StartupController() class but I want to run the GetString() function in the HelloApiController() class and pass the string variable. The method I am using doesn't work, is there something I am missing?

public class StartupController()
{
    [HttpPost]
    [Route("api/forge/run")]
    public async Task<dynamic> Home()
    {
        string text = "Hello Api";
        RedirectToRoute("api/forge/String", "text");
        return null;
    }
}

public class HelloApiController()
{
    [HttpGet]
    [Route("api/forge/String")]
    public async Task<dynamic> GetString(string text)
    {        
        return text;
    }
}
Nathan Hurley
  • 136
  • 1
  • 1
  • 12

0 Answers0