In Umbraco 9 is seems like the only available Index action for controllers is:
public IActionResult Index()
but I want to use an async index action:
public async Task<IActionResult> Index()
in order to call async code that I have in my business logic. Else I will have to make a sync to async transition that causes bad performance and possible deadlock problems.
I've tried making my own controller that inherits from Microsofts controller but it seems like Umbraco is unable to pick it when looking for controllers. And I assume that is because Umbraco expects the signature to be the synchronous one.
Anyone knows if this is possible or have a suggestion on how I should do it.
How do I support async controllers actions?
Hello
In Umbraco 9 is seems like the only available Index action for controllers is:
but I want to use an async index action:
in order to call async code that I have in my business logic. Else I will have to make a sync to async transition that causes bad performance and possible deadlock problems.
I've tried making my own controller that inherits from Microsofts controller but it seems like Umbraco is unable to pick it when looking for controllers. And I assume that is because Umbraco expects the signature to be the synchronous one.
Anyone knows if this is possible or have a suggestion on how I should do it.
Regards Fredrik
Depending on what you're trying to accomplish you should probably inherit from one of the Umbraco controllers and not a Microsoft controller.
As for the code, the code below works for me using IHttpActionResult in a web api controller
Thanks
I want the Index method for all the controllers serving pages to be async because I have async business logic code that I want to execute.
This worked in Umbraco 8 but in 9 I'm unable to create a controller with an index action that is async.
is working on a reply...