I think you are running into a deadlock because of RunAsync().Wait();
. Your Test()
Method is blocking the context thread, waiting for RunAsync()
to complete and RunAsync()
is waiting for the context to be free so it can complete. This blog from Stephen Cleary describes the problem in detail: link.
The solution would be changing the signature to allow "awaiting" on RunAsync()
:
public ActionResult Test()
to public async Task<ActionResult> Test()
and
RunAsync().Wait();
to await RunAsync();