the required code in the controller should be moved to a common module called by both startup and the controller.
note: at startup there is no request, so httpcontext, etc is null.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I got a .NET Core application, using Angular as a frontend. I have a controller that needs to be triggered before the website is launched. In order to make that happen, I wish I could call the method inside the controller from the Startup class, but it seems to be a bad practice.
How can accomplish this? Can you please provide me an line of code on how to call a method that is inside a controller?
the required code in the controller should be moved to a common module called by both startup and the controller.
note: at startup there is no request, so httpcontext, etc is null.
The class that I need to call is inside a controller. That class is coded like this:
public async Task<IActionResult> InitiateSignOn(string returnUrl = null)
{
var partnerName = _configuration[PartnerName];
await = _ServiceProvider.InitatiateSignOn(partnerName, returnUrl);
return new EmptyReturn();
}
So if I move the above class into a Helper Class. Then, I'm not sure if the code in controller would work. Please advise. Thanks