HttpClient PostAsync() never return response
Since you are using .Result
or .Wait
or await
this will end up causing a deadlock in your code.
you can use ConfigureAwait(false)
in async
methods for preventing deadlock
like this:
string responseContent = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
you can use
ConfigureAwait(false)
wherever possible for Don't Block Async Code .
Since you are using .Result
, this will end up causing a deadlock in your code. The reason this is working in a console application is because console applications don't have contexts, but ASP.NET apps do (see Stephen Cleary's Don't Block on Async Code). You should make the Signin
method in your controller async
and await
the call to _authenticationService.Authenticate
to resolve the deadlock issue.