One of the developers in my team complained that one of the ASP.NET Web API requests was really slow and asked me to investigate the performance issue.
When I opened the solution I saw the following code:
Do you notice what’s wrong?
The problem is that inside the validator an async call is done where if you look at the controller the validator is invoked in a synchronous way. This causes the API to hang as ASP.NET keeps waiting for a result that is never returned.
The solution was simple; just switch to the ValidateAsync method and await the result in the controller: